ID: 25975
User updated by: reiersol at online dot no
Reported By: reiersol at online dot no
Status: Open
Bug Type: Session related
Operating System: Linux RedHat 9.0
PHP Version: 5CVS-2003-10-24 (dev)
New Comment:
The last line of the code example (print $1) is meaningless. Sorry.
Previous Comments:
------------------------------------------------------------------------
[2003-10-24 08:08:59] reiersol at online dot no
Description:
------------
Object references inside PHP5 objects are not preserved through
serialize/unserialize like traditional PHP4 references. This means they
cannot be used in session-based applications.
Reproduce code:
---------------
class Bar {}
class Foo {
var $v1;
var $v2;
function Foo() {
$this->v1 = new Bar;
$this->v2 = $this->v1;
}
}
$f = new Foo;
var_dump($f);
$g = unserialize(serialize($f));
var_dump($g);
print $s1;
Expected result:
----------------
This is what I get if I use $this->v2 = &this->$v1 instead of $this->v2
= $this->v1:
object(foo)#1 (2) {
["v1"]=>
&object(bar)#2 (0) {
}
["v2"]=>
&object(bar)#2 (0) {
}
}
object(foo)#3 (2) {
["v1"]=>
&object(bar)#4 (0) {
}
["v2"]=>
&object(bar)#4 (0) {
}
}
Actual result:
--------------
object(foo)#1 (2) {
["v1"]=>
object(bar)#2 (0) {
}
["v2"]=>
object(bar)#2 (0) {
}
}
object(foo)#3 (2) {
["v1"]=>
object(bar)#4 (0) {
}
["v2"]=>
object(bar)#5 (0) {
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25975&edit=1