From efc550eea35ddfc9c5c02ee5cd4aea3c00b36f16 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 11 Aug 2003 04:57:55 +0000 Subject: [PATCH] MFH: Fixed bug #21957 (serialize() mangles objects with __sleep). --- NEWS | 1 + ext/standard/tests/serialize/bug21957.phpt | 2 +- ext/standard/var.c | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index a810e6730b..13f2cab58e 100644 --- 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) diff --git a/ext/standard/tests/serialize/bug21957.phpt b/ext/standard/tests/serialize/bug21957.phpt index af2003f3e3..82b5e5fd4d 100644 --- a/ext/standard/tests/serialize/bug21957.phpt +++ b/ext/standard/tests/serialize/bug21957.phpt @@ -33,7 +33,7 @@ array(2) { ["one"]=> string(3) "ABC" ["two"]=> - object(test)#1 (2) { + object(test)(2) { ["a"]=> int(7) ["b"]=> diff --git a/ext/standard/var.c b/ext/standard/var.c index 628d0c372b..8a889ded3f 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -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); -- 2.50.1