1--TEST-- 2Bug #71940 (Unserialize crushes on restore object reference) 3--FILE-- 4<?php 5 6class Identity 7{ 8 private $role; 9 10 public function __construct($role) 11 { 12 $this->role = $role; 13 } 14} 15 16class Entry implements \Serializable 17{ 18 private $identity; 19 20 public function __construct(Identity $identity) 21 { 22 $this->identity = $identity; 23 } 24 25 public function serialize() 26 { 27 return serialize(array($this->identity)); 28 } 29 30 public function unserialize($serialized) 31 { 32 list($this->identity) = unserialize($serialized); 33 } 34} 35 36$identity = new Identity('test'); 37$identityRef = &$identity; 38 39$entry1 = new Entry($identity); 40$entry2 = new Entry($identityRef); 41 42$serialized = serialize([$entry1, $entry2]); 43print_r(unserialize($serialized)); 44 45?> 46--EXPECTF-- 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 48Array 49( 50 [0] => Entry Object 51 ( 52 [identity:Entry:private] => Identity Object 53 ( 54 [role:Identity:private] => test 55 ) 56 57 ) 58 59 [1] => Entry Object 60 ( 61 [identity:Entry:private] => Identity Object 62 ( 63 [role:Identity:private] => test 64 ) 65 66 ) 67 68) 69