summaryrefslogtreecommitdiff
path: root/ext/standard/tests/serialize/bug72610_3.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/tests/serialize/bug72610_3.phpt')
-rw-r--r--ext/standard/tests/serialize/bug72610_3.phpt49
1 files changed, 49 insertions, 0 deletions
diff --git a/ext/standard/tests/serialize/bug72610_3.phpt b/ext/standard/tests/serialize/bug72610_3.phpt
new file mode 100644
index 0000000000..4e690878d5
--- /dev/null
+++ b/ext/standard/tests/serialize/bug72610_3.phpt
@@ -0,0 +1,49 @@
+--TEST--
+__wakeup should be able to modify dynamic properties without affecting copies of those properties
+--FILE--
+<?php
+
+class Obj {
+ // Testing $this->a being a dynamic property.
+
+ function __construct($a) {
+ $this->a = $a;
+ }
+
+ public function __wakeup() {
+ echo "Calling __wakeup " . json_encode($this->a) . "\n";
+ $this->a = "roh";
+ }
+}
+
+function main() {
+ $obj = new stdClass();
+ $obj->c = null;
+ $variable = [new Obj($obj), new Obj($obj), $obj];
+ $serialized = serialize($variable);
+ printf("%s\n", $serialized);
+ $unserialized = unserialize($serialized);
+ var_dump($unserialized);
+}
+main();
+--EXPECTF--
+a:3:{i:0;O:3:"Obj":1:{s:1:"a";O:8:"stdClass":1:{s:1:"c";N;}}i:1;O:3:"Obj":1:{s:1:"a";r:3;}i:2;r:3;}
+Calling __wakeup {"c":null}
+Calling __wakeup {"c":null}
+array(3) {
+ [0]=>
+ object(Obj)#%d (1) {
+ ["a"]=>
+ string(3) "roh"
+ }
+ [1]=>
+ object(Obj)#%d (1) {
+ ["a"]=>
+ string(3) "roh"
+ }
+ [2]=>
+ object(stdClass)#%d (1) {
+ ["c"]=>
+ NULL
+ }
+}