2003-08-11 03:22:24 +00:00
|
|
|
--TEST--
|
|
|
|
Bug #21957 (serialize() mangles objects with __sleep)
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
class test
|
|
|
|
{
|
2003-11-30 13:57:20 +00:00
|
|
|
public $a, $b;
|
2003-08-11 03:22:24 +00:00
|
|
|
|
|
|
|
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--
|
2006-03-27 13:37:47 +00:00
|
|
|
array(2) {
|
|
|
|
[u"one"]=>
|
|
|
|
unicode(3) "ABC"
|
|
|
|
[u"two"]=>
|
|
|
|
object(test)#1 (2) {
|
|
|
|
[u"a"]=>
|
|
|
|
int(7)
|
|
|
|
[u"b"]=>
|
|
|
|
int(2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
a:2:{U:3:"one";U:3:"ABC";U:3:"two";N;}
|
|
|
|
array(2) {
|
|
|
|
[u"one"]=>
|
|
|
|
unicode(3) "ABC"
|
|
|
|
[u"two"]=>
|
|
|
|
NULL
|
|
|
|
}
|