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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
--TEST--
__wakeup can modify properties without affecting other objects
--FILE--
<?php
class Obj {
private static $count = 1;
public $a;
function __construct($a) {
$this->a = $a;
}
public function __wakeup() {
echo "call wakeup\n";
$this->a[] = "end";
}
}
function main() {
$array = ["test"]; // array (not a reference, but should be copied on write)
$a = new Obj($array);
$b = new Obj($array);
$variable = [$a, $b];
$serialized = igbinary_serialize($variable);
printf("%s\n", bin2hex($serialized));
$unserialized = igbinary_unserialize($serialized);
var_dump($unserialized);
}
main();
--EXPECTF--
000000021402060017034f626a14011101611401060011047465737406011a0014010e010102
call wakeup
call wakeup
array(2) {
[0]=>
object(Obj)#%d (1) {
["a"]=>
array(2) {
[0]=>
string(4) "test"
[1]=>
string(3) "end"
}
}
[1]=>
object(Obj)#%d (1) {
["a"]=>
array(2) {
[0]=>
string(4) "test"
[1]=>
string(3) "end"
}
}
}
|