1--TEST--
2Bug #31402 (unserialize() generates references when it should not)
3--INI--
4error_reporting=E_ALL
5--FILE--
6<?php
7
8class TestX {
9  var $i;
10
11  function __construct($i) {
12    $this->i = $i;
13  }
14}
15
16class TestY {
17  var $A = array();
18  var $B;
19
20  function __construct() {
21    $this->A[1] = new TestX(1);
22    $obj = new TestX(2);
23    $this->A[2] = & $obj;
24    $this->A[3] = & $this->A[2];
25    $this->B = $this->A[1];
26  }
27}
28
29$before = new TestY();
30$ser = serialize($before);
31$after = unserialize($ser);
32
33var_dump($before, $after);
34
35?>
36===DONE===
37--EXPECTF--
38object(TestY)#%d (2) {
39  ["A"]=>
40  array(3) {
41    [1]=>
42    object(TestX)#%d (1) {
43      ["i"]=>
44      int(1)
45    }
46    [2]=>
47    &object(TestX)#%d (1) {
48      ["i"]=>
49      int(2)
50    }
51    [3]=>
52    &object(TestX)#%d (1) {
53      ["i"]=>
54      int(2)
55    }
56  }
57  ["B"]=>
58  object(TestX)#%d (1) {
59    ["i"]=>
60    int(1)
61  }
62}
63object(TestY)#%d (2) {
64  ["A"]=>
65  array(3) {
66    [1]=>
67    object(TestX)#%d (1) {
68      ["i"]=>
69      int(1)
70    }
71    [2]=>
72    &object(TestX)#%d (1) {
73      ["i"]=>
74      int(2)
75    }
76    [3]=>
77    &object(TestX)#%d (1) {
78      ["i"]=>
79      int(2)
80    }
81  }
82  ["B"]=>
83  object(TestX)#%d (1) {
84    ["i"]=>
85    int(1)
86  }
87}
88===DONE===
89