summaryrefslogtreecommitdiff
path: root/ext/standard/tests/serialize/bug72610_2.phpt
blob: bb0634277e9029ce5a7f2facf3632cf1b809052a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--TEST--
__wakeup can replace a copy of the object referring to the root node.
--FILE--
<?php
/* This bug never happened, but adding this test to make sure that further changes to unserialize don't allow freeing the root in __wakeup. */
class Obj {
	function __construct($a) {
		$this->a = $a;
	}

	public function __wakeup() {
		echo "Calling __wakeup\n";
		$this->a = "replaced";
	}
}

$a = new stdClass();
$a->obj = new Obj($a);;
$serialized = serialize($a);
printf("%s\n", $serialized);
$unserialized = unserialize($serialized);
var_dump($unserialized);
--EXPECTF--
O:8:"stdClass":1:{s:3:"obj";O:3:"Obj":1:{s:1:"a";r:1;}}
Calling __wakeup
object(stdClass)#%d (1) {
  ["obj"]=>
  object(Obj)#%d (1) {
    ["a"]=>
    string(8) "replaced"
  }
}