Bug #16073 Updated: Cannot unserialize() a string serialized with serialize()

From: Date: Sun, 07 Jul 2002 16:53:03 +0000
Subject: Bug #16073 Updated: Cannot unserialize() a string serialized with serialize()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-13391@lists.php.net to get a copy of this message
ID: 16073 Updated by: derick@php.net Reported By: ahristov@icygen.com Status: Open -Bug Type: Variables related +Bug Type: Feature/Change Request Operating System: RH 7.1 PHP Version: 4.0CVS-2002-03-14 Previous Comments: ------------------------------------------------------------------------ [2002-03-14 10:20:54] ahristov@icygen.com Not sure if this is a bug but serialize() cannot work with arrays that holds elements which points to the array itself <?php $b=array(1,2,4); $b[]=&$b; $str=serialize($b); var_dump($b); var_dump($str); $c=unserialize($str); var_dump($c); ?> The ouput is: array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(4) [3]=> *RECURSION* } string(64) "a:4:{i:0;i:1;i:1;i:2;i:2;i:4;i:3;a:4:{i:0;i:1;i:1;i:2;i:2;i:4;}}" bool(false) If $b[]=&$b; removed the output is: array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(4) } string(30) "a:3:{i:0;i:1;i:1;i:2;i:2;i:4;}" array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(4) } That's ok. Serialize() have either to check against recursion or encode somehow the recursion in the serialized(great BC impact). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16073&edit=1

« previous php.bugs (#13391) next »