]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #21957 (serialize() mangles objects with __sleep).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 11 Aug 2003 04:57:55 +0000 (04:57 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 11 Aug 2003 04:57:55 +0000 (04:57 +0000)
NEWS
ext/standard/tests/serialize/bug21957.phpt
ext/standard/var.c

diff --git a/NEWS b/NEWS
index a810e6730b74ae67b1e790fa34cf5b35aeffa133..13f2cab58e82e00778e7686d83ea7f0d1673de57 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ PHP 4                                                                      NEWS
 - Fixed bug #24142 (workaround for a gcc bug affecting round()). (Marcus, Ilia)
 - Fixed bug #24063 (serialize() missing 0 after the . on scientific notation).
   (Marcus, Ilia)
+- Fixed bug #21957 (serialize() mangles objects with __sleep). (Ilia)
 
 07 Aug 2003, Version 4.3.3RC3
 - Fixed bug #24958 (Incorrect handling of 404s). (Ilia, Justin)
index af2003f3e39bb31deb47aefeda4006fb97bae0e4..82b5e5fd4d72a87b12130a311d1273d5744e69a7 100644 (file)
@@ -33,7 +33,7 @@ array(2) {
   ["one"]=>
   string(3) "ABC"
   ["two"]=>
-  object(test)#1 (2) {
+  object(test)(2) {
     ["a"]=>
     int(7)
     ["b"]=>
index 628d0c372ba6e806bc97775ad9d193ce67ea27c1..8a889ded3fc5bd9b55e9e71aabd361f444e0452c 100644 (file)
@@ -462,7 +462,7 @@ static void php_var_serialize_class(smart_str *buf, zval **struc, zval *retval_p
                                                "serialize.");
                                /* we should still add element even if it's not OK,
                                   since we already wrote the length of the array before */
-                               smart_str_appendl(buf,"s:0:\"\";N;", 9);
+                               smart_str_appendl(buf,"N;", 2);
                                continue;
                        }
 
@@ -543,6 +543,9 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va
                                                        php_error_docref(NULL TSRMLS_CC, E_NOTICE, "__sleep should return an array only "
                                                                                                "containing the names of instance-variables to "
                                                                                                "serialize.");
+                                                       /* we should still add element even if it's not OK,
+                                                          since we already wrote the length of the array before */
+                                                       smart_str_appendl(buf,"N;", 2);
                                                }
 
                                                zval_ptr_dtor(&retval_ptr);