From: reiersol at online dot no Operating system: Linux RedHat 9.0 PHP version: 5CVS-2003-10-24 (dev) PHP Bug Type: Session related Bug description: PHP 5 object references don't survive serialization
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 bug report at http://bugs.php.net/?id=25975&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25975&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25975&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25975&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25975&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25975&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25975&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25975&r=support Expected behavior: http://bugs.php.net/fix.php?id=25975&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25975&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25975&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25975&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25975&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25975&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25975&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25975&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=25975&r=float