iliaa Mon Aug 11 00:57:56 2003 EDT
Added files: (Branch: PHP_4_3)
/php-src/ext/standard/tests/serialize bug21957.phpt
Modified files:
/php-src/ext/standard var.c
/php-src NEWS
Log:
MFH: Fixed bug #21957 (serialize() mangles objects with __sleep).
Index: php-src/ext/standard/var.c
diff -u php-src/ext/standard/var.c:1.150.2.8 php-src/ext/standard/var.c:1.150.2.9
--- php-src/ext/standard/var.c:1.150.2.8 Wed May 7 21:23:36 2003
+++ php-src/ext/standard/var.c Mon Aug 11 00:57:55 2003
@@ -462,7 +462,7 @@
"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 @@
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);
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.337 php-src/NEWS:1.1247.2.338
--- php-src/NEWS:1.1247.2.337 Sun Aug 10 20:43:32 2003
+++ php-src/NEWS Mon Aug 11 00:57:55 2003
@@ -15,6 +15,7 @@
- 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: php-src/ext/standard/tests/serialize/bug21957.phpt
+++ php-src/ext/standard/tests/serialize/bug21957.phpt
--TEST--
Bug #21957 (serialize() mangles objects with __sleep)
--FILE--
<?php
class test
{
var $a, $b;
function test()
{
$this->a = 7;
$this->b = 2;
}
function __sleep()
{
$this->b = 0;
}
}
$t['one'] = 'ABC';
$t['two'] = new test();
var_dump($t);
$s = @serialize($t);
echo $s . "\n";
var_dump(unserialize($s));
?>
--EXPECT--
array(2) {
["one"]=>
string(3) "ABC"
["two"]=>
object(test)#1 (2) {
["a"]=>
int(7)
["b"]=>
int(2)
}
}
a:2:{s:3:"one";s:3:"ABC";s:3:"two";N;}
array(2) {
["one"]=>
string(3) "ABC"
["two"]=>
NULL
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php