From: antonr at game dot permonline dot ru
Operating system: Win32
PHP version: 5CVS-2004-05-08 (dev)
PHP Bug Type: Class/Object related
Bug description: serialization of objects
Description:
------------
I have one object with property "myclass1", referenced to second object.
And property "myclass2" of second object, referenced to first object.
When I serialize the first object and unserialize the result string, I get
three objects: two copies of first object and a copy of second object.
Reproduce code:
---------------
<?php
class MyClass1
{ public $myclass2;
public $number;
}
class MyClass2
{ public $myclass1;
}
$a = new MyClass1;
$a->number = 1;
$a->myclass2 = new MyClass2;
$a->myclass2->myclass1 = $a;
$b = unserialize(serialize($a));
$b->number = 2;
echo $b->number;
echo "\n";
echo $b->myclass2->myclass1->number;
?>
Expected result:
----------------
If serialization was made correctly, then we would get that
$b and $b->myclass2->myclass1 are references to one instance, and the
output of script must be:
2
2
Actual result:
--------------
The actual output is
2
1
this means, that $b and $b->myclass2->myclass1 aren't references to the
same instance
--
Edit bug report at http://bugs.php.net/?id=28325&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28325&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28325&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28325&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28325&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28325&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28325&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28325&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28325&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28325&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28325&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28325&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28325&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28325&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28325&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28325&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28325&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28325&r=float