1--TEST-- 2Bug #36424 - Serializable interface breaks object references 3--FILE-- 4<?php 5 6class a implements Serializable { 7 function serialize() { 8 return serialize(get_object_vars($this)); 9 } 10 function unserialize($s) { 11 foreach (unserialize($s) as $p=>$v) { 12 $this->$p=$v; 13 } 14 } 15} 16class b extends a {} 17class c extends b {} 18 19$c = new c; 20$c->a = new a; 21$c->a->b = new b; 22$c->a->b->c = $c; 23$c->a->c = $c; 24$c->a->b->a = $c->a; 25$c->a->a = $c->a; 26 27$s = serialize($c); 28printf("%s\n", $s); 29 30$d = unserialize($s); 31 32var_dump( 33 $d === $d->a->b->c, 34 $d->a->a === $d->a, 35 $d->a->b->a === $d->a, 36 $d->a->c === $d 37); 38 39print_r($d); 40 41echo "Done\n"; 42 43?> 44--EXPECTF-- 45Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d 46 47Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d 48 49Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d 50C:1:"c":108:{a:1:{s:1:"a";C:1:"a":81:{a:3:{s:1:"b";C:1:"b":30:{a:2:{s:1:"c";r:1;s:1:"a";r:3;}}s:1:"c";r:1;s:1:"a";r:3;}}}} 51bool(true) 52bool(true) 53bool(true) 54bool(true) 55c Object 56( 57 [a] => a Object 58 ( 59 [b] => b Object 60 ( 61 [c] => c Object 62 *RECURSION* 63 [a] => a Object 64 *RECURSION* 65 ) 66 67 [c] => c Object 68 *RECURSION* 69 [a] => a Object 70 *RECURSION* 71 ) 72 73) 74Done 75