ID: 33586 Updated by: [EMAIL PROTECTED] Reported By: wmeler at wp dot pl -Status: Open +Status: Assigned Bug Type: Scripting Engine problem Operating System: * PHP Version: 5CVS-2005-07-06 -Assigned To: +Assigned To: dmitry
Previous Comments: ------------------------------------------------------------------------ [2005-07-22 08:52:12] wmeler at wp dot pl Do you want simplest to debug example or complicated real world example? How about this : <? $c = array(); $d = array(); $c['d2']=&$d; $d['c2']=&$c; $x=unserialize(serialize($c)); $x['x']='x'; $c['x']='x'; var_dump($c); var_dump($x); ?> outputs remain the same you can even substitute 'c' with 'parent' and 'd' with 'child' which makes it more real but this would change outputs ------------------------------------------------------------------------ [2005-07-22 01:03:09] [EMAIL PROTECTED] In your example you're making a reference to a non-existing variable. Please come up with something more realistic. ------------------------------------------------------------------------ [2005-07-06 12:51:21] wmeler at wp dot pl I've tried - nothing changed ------------------------------------------------------------------------ [2005-07-06 12:17:00] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-07-06 12:03:59] wmeler at wp dot pl 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 this bug report at http://bugs.php.net/?id=33586&edit=1