|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-07-26 00:58 UTC] magnus@php.net
[2003-07-27 14:11 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 07:00:01 2025 UTC |
Description: ------------ Can't upgrade, production environment. Happens on 4.2.2 and earlier, and I'm forced to assume that it's still happening on more modern versions. Ran into this problem with a much more complicated piece of code. Basically, I have an array nested in an object. The array contains other objects that then reference the parent object ala circular linked-list. The provided example uses print_r to create an overflow, though my actual code the overflow happens elsewhere (I can't figure out where in my code the overflow is being generated, since I never actually traversed the list, as print_r does). I know that it's the same problem because both print_r and my code stabilize the instant I remove the recursive entry from the second object (luckily for me, it wasn't needed). Reproduce code: --------------- class a { var $items = array(); function a() { } } class b { var $a; function b(&$a) { $this->a = &$a; } } $a = new a(); $a->items[] = new b($a); $a->items[] = new b($a); $a->items[] = new b($a); # this much is ok $a->items[] = new b($a); # the proverbial straw print_r($a); Expected result: ---------------- get a printout from print_r where all recursive entries are marked: a Object ( [items] => Array ( [0] => b Object (# [a] => *RECURSION* ) [1] => b Object ( [a] => *RECURSION* ) ) ) Actual result: -------------- With fewer items, the recursion is not properly detected, leading to an overflow as more items are added. With too many items in the array, nothing. php dies, or something like that. IE produces a "page not found" error, and gecko just redisplays whatever page was previously loaded, with no error returned (I expected a "document contains no data" error, but never got it).