Re: serialize bug with array that references to itself?

From: Date: Wed, 03 Nov 2004 16:37:35 +0000
Subject: Re: serialize bug with array that references to itself?
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-13712@lists.php.net to get a copy of this message
Andrey Hristov wrote:
Well, when there is traversion inside the engine, it checks whether it has processed a "node" already several times. As far as I remember the threshold is 3. So once it goes over $Arr, the counter increases to 1, the second time to 2 and third time it is 3 and ZE reports recursion.
is there good reason to set the threshold at 3 iso 2? when dumping out objects that make heavy use of 'parent' references this leads to tons of extra output which would be greatly cutdown if the threshold was 2 iso 3. just to make the point, print_r seems to use a threshold of 2 (which is why I always try print_r before taking my chances with var_dump): <?php class a { public $self; } $A = new a; $A->self = $A; var_dump( $A ); print_r( $A ); ?>
HTH, Andrey Francisco M. Marzoa Alonso wrote:
BTW., I'm not sure that there's nothing more wrong here. Takin the first part of the code of first example: <?php $Arr = array(); $Arr['self'] = &$Arr; var_dump ( $Arr ); ?> It returns: array(1) { ["self"]=> array(1) { ["self"]=> *RECURSION* } } Is that as its expected to be? I meant that perhaps it should be: array(1) { ["self"]=> *RECURSION* } Since the element in $Arr['self'] is yet (or at least should be) a reference to itself...


« previous php.internals (#13712) next »