From: wmeler at wp dot pl
Operating system: Any
PHP version: 5.0.4
PHP Bug Type: Variables related
Bug description: Serialization breaks references
Description:
------------
After serializing variable with circular reference you get 2 copies of
root variable.
Look at output of reproduce code - var_dump outputs should be the same but
they are not.
for code:
$c['d2']=&$d;
$d['c2']=&$c;
echo serialize($c);
you get
a:1:{s:2:"d2";a:1:{s:2:"c2";a:1:{s:2:"d2";R:2;}}}
I think that it should be something like
a:1:{s:2:"d2";a:1:{s:2:"c2";R:1;}}
Reproduce code:
---------------
<?
$c['d2']=&$d;
$d['c2']=&$c;
$x=unserialize(serialize($c));
$x['x']='x';
$c['x']='x';
var_dump($c);
var_dump($x);
Expected result:
----------------
array(2) {
["d2"]=>
&array(1) {
["c2"]=>
&array(2) {
["d2"]=>
&array(1) {
["c2"]=>
&array(2) {
["d2"]=>
*RECURSION*
["x"]=>
string(1) "x"
}
}
["x"]=>
string(1) "x"
}
}
["x"]=>
string(1) "x"
}
array(2) {
["d2"]=>
&array(1) {
["c2"]=>
&array(2) {
["d2"]=>
&array(1) {
["c2"]=>
&array(2) {
["d2"]=>
*RECURSION*
["x"]=>
string(1) "x"
}
}
["x"]=>
string(1) "x"
}
}
["x"]=>
string(1) "x"
}
Actual result:
--------------
array(2) {
["d2"]=>
&array(1) {
["c2"]=>
&array(2) {
["d2"]=>
&array(1) {
["c2"]=>
&array(2) {
["d2"]=>
*RECURSION*
["x"]=>
string(1) "x"
}
}
["x"]=>
string(1) "x"
}
}
["x"]=>
string(1) "x"
}
array(2) {
["d2"]=>
&array(1) {
["c2"]=>
array(1) {
["d2"]=>
&array(1) {
["c2"]=>
array(1) {
["d2"]=>
*RECURSION*
}
}
}
}
["x"]=>
string(1) "x"
}
--
Edit bug report at http://bugs.php.net/?id=33586&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33586&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33586&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33586&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33586&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33586&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33586&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33586&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33586&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33586&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33586&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33586&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33586&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33586&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33586&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33586&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33586&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33586&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33586&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33586&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33586&r=mysqlcfg