1--TEST-- 2Bug #21957 (serialize() mangles objects with __sleep) 3--FILE-- 4<?php 5class test 6{ 7 public $a, $b; 8 9 function test() 10 { 11 $this->a = 7; 12 $this->b = 2; 13 } 14 15 function __sleep() 16 { 17 $this->b = 0; 18 } 19} 20 21$t['one'] = 'ABC'; 22$t['two'] = new test(); 23 24var_dump($t); 25 26$s = @serialize($t); 27echo $s . "\n"; 28 29var_dump(unserialize($s)); 30?> 31--EXPECT-- 32array(2) { 33 ["one"]=> 34 string(3) "ABC" 35 ["two"]=> 36 object(test)#1 (2) { 37 ["a"]=> 38 int(7) 39 ["b"]=> 40 int(2) 41 } 42} 43a:2:{s:3:"one";s:3:"ABC";s:3:"two";N;} 44array(2) { 45 ["one"]=> 46 string(3) "ABC" 47 ["two"]=> 48 NULL 49} 50