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--
47Array
48(
49    [0] => Entry Object
50        (
51            [identity:Entry:private] => Identity Object
52                (
53                    [role:Identity:private] => test
54                )
55
56        )
57
58    [1] => Entry Object
59        (
60            [identity:Entry:private] => Identity Object
61                (
62                    [role:Identity:private] => test
63                )
64
65        )
66
67)
68