#33586 [Opn->Fbk]: Serialization breaks references

From: Date: Thu, 21 Jul 2005 23:03:10 +0000
Subject: #33586 [Opn->Fbk]: Serialization breaks references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-82298@lists.php.net to get a copy of this message
ID: 33586 Updated by: sniper@php.net Reported By: wmeler at wp dot pl -Status: Open +Status: Feedback Bug Type: Scripting Engine problem Operating System: * PHP Version: 5CVS-2005-07-06 New Comment: In your example you're making a reference to a non-existing variable. Please come up with something more realistic. Previous Comments: ------------------------------------------------------------------------ [2005-07-06 12:51:21] wmeler at wp dot pl I've tried - nothing changed ------------------------------------------------------------------------ [2005-07-06 12:17:00] tony2001@php.net 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

« previous php.bugs (#82298) next »