Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13708 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1681 invoked by uid 1010); 3 Nov 2004 14:59:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 1653 invoked from network); 3 Nov 2004 14:59:37 -0000 Received: from unknown (HELO mail.gmx.net) (213.165.64.20) by pb1.pair.com with SMTP; 3 Nov 2004 14:59:37 -0000 Received: (qmail 32554 invoked by uid 65534); 3 Nov 2004 14:59:36 -0000 Received: from 55.Red-213-4-20.pooles.rima-tde.net (EHLO [10.10.0.21]) (213.4.20.55) by mail.gmx.net (mp004) with SMTP; 03 Nov 2004 15:59:36 +0100 X-Authenticated: #12441595 Message-ID: <4189013F.2050104@gmx.net> Date: Wed, 03 Nov 2004 17:03:11 +0100 User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals References: <4188DEC8.5060309@gmx.net> <4188DDC9.30000@hristov.com> In-Reply-To: <4188DDC9.30000@hristov.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] serialize bug with array that references to itself? From: fmmarzoa@gmx.net ("Francisco M. Marzoa Alonso") Should I fill a bug notification report or so? (where are them? ;-)) Andrey Hristov wrote: > 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) > > class a{} > class b{} > > $a=new a; > $b=new b; > $a->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 : > class a{} > class b{} > > $a=new a; > $b=new b; > $a->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 >