Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13706 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84369 invoked by uid 1010); 3 Nov 2004 13:35:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 80796 invoked from network); 3 Nov 2004 13:34:37 -0000 Received: from unknown (HELO iko.gotobg.net) (80.168.8.116) by pb1.pair.com with SMTP; 3 Nov 2004 13:34:37 -0000 Received: from pd95e9886.dip.t-dialin.net ([217.94.152.134] helo=[192.168.0.36]) by iko.gotobg.net with esmtpa (Exim 4.43) id 1CPLHZ-0003Dk-Ls; Wed, 03 Nov 2004 15:34:38 +0200 Message-ID: <4188DDC9.30000@hristov.com> Date: Wed, 03 Nov 2004 14:31:53 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a4) Gecko/20040918 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Francisco M. Marzoa Alonso" CC: internals References: <4188DEC8.5060309@gmx.net> In-Reply-To: <4188DEC8.5060309@gmx.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] serialize bug with array that references to itself? From: php@hristov.com (Andrey Hristov) Francisco M. Marzoa Alonso wrote: > Try this code: > >
>  
> $Arr = array();
> $Arr['self'] = &$Arr;
> var_dump ( $Arr );
> 
> $serdata = serialize ($Arr);
> $Arr2 = unserialize ( $serdata );
> echo "\n\n";
> var_dump ( $Arr2 );
> 
> ?>
> 
> > The second array is expected to be exactly as $Arr, but it doesn't. This > is the output for that code: > > array(1) { > ["self"]=> > array(1) { > ["self"]=> > *RECURSION* > } > } > > array(1) { > ["self"]=> > array(1) { > ["self"]=> > NULL > } > } > > As you can see the second array has a NULL value where the first one had > a recursive reference. > > Can this be considered as a bug of PHP serialization system? > Looks as such. While looking at this one, I cooked a little example which cores ZE2 (5.1.0-dev) a=$b; $c=array($a,$b); var_dump($c,$d=serialize($c)); var_dump($e=unserialize($d)); $d[0]->a->prop=1; var_dump($d); ?> If one looks at it she will see that I have an error in the example and instead of $d[0]->a I have to use $e[0] , still a Segmentation Fault is not tolerable. This works ok : a=$b; $c=array($a,$b); var_dump($c, $d=serialize($c)); var_dump($e=unserialize($d)); $d[0]->a->prop=1; var_dump($d); ?> $e is : array(2) { [0]=> object(a)#3 (1) { ["a"]=> object(b)#4 (1) { ["prop"]=> int(1) } } [1]=> object(b)#4 (1) { ["prop"]=> int(1) } } Andrey