php-src/ext/standard/tests/serialize/bug31402.phpt

88 lines
1.2 KiB
Plaintext
Raw Normal View History

2005-01-18 11:36:44 +00:00
--TEST--
Bug #31402 (unserialize() generates references when it should not)
2005-03-11 00:11:35 +00:00
--INI--
error_reporting=E_ALL&~E_STRICT
2005-01-18 11:36:44 +00:00
--FILE--
<?php
2005-03-11 00:11:35 +00:00
class TestX {
2005-01-18 11:36:44 +00:00
var $i;
2005-03-11 00:11:35 +00:00
function __construct($i) {
2005-01-18 11:36:44 +00:00
$this->i = $i;
}
}
2005-03-11 00:11:35 +00:00
class TestY {
2005-01-18 11:36:44 +00:00
var $A = array();
var $B;
2005-03-11 00:11:35 +00:00
function __construct() {
$this->A[1] = new TestX(1);
$this->A[2] = & new TestX(2);
$this->A[3] = & $this->A[2];
2005-01-18 11:36:44 +00:00
$this->B = $this->A[1];
}
}
2005-03-11 00:11:35 +00:00
$before = new TestY();
2005-01-18 11:36:44 +00:00
$ser = serialize($before);
$after = unserialize($ser);
var_dump($before, $after);
?>
===DONE===
2005-03-11 00:11:35 +00:00
--EXPECTF--
object(TestY)#%d (2) {
2005-01-18 11:36:44 +00:00
["A"]=>
array(3) {
2005-01-18 11:36:44 +00:00
[1]=>
2005-03-11 00:11:35 +00:00
object(TestX)#%d (1) {
2005-01-18 11:36:44 +00:00
["i"]=>
int(1)
}
[2]=>
&object(TestX)#%d (1) {
["i"]=>
int(2)
}
[3]=>
&object(TestX)#%d (1) {
2005-01-18 11:36:44 +00:00
["i"]=>
int(2)
}
}
["B"]=>
2005-03-11 00:11:35 +00:00
object(TestX)#%d (1) {
2005-01-18 11:36:44 +00:00
["i"]=>
int(1)
}
}
2005-03-11 00:11:35 +00:00
object(TestY)#%d (2) {
2005-01-18 11:36:44 +00:00
["A"]=>
array(3) {
2005-01-18 11:36:44 +00:00
[1]=>
object(TestX)#%d (1) {
2005-01-18 11:36:44 +00:00
["i"]=>
int(1)
}
[2]=>
&object(TestX)#%d (1) {
["i"]=>
int(2)
}
[3]=>
&object(TestX)#%d (1) {
2005-01-18 11:36:44 +00:00
["i"]=>
int(2)
}
}
["B"]=>
object(TestX)#%d (1) {
2005-01-18 11:36:44 +00:00
["i"]=>
int(1)
}
}
===DONE===