|
Title: Recurse Function Causing Apache Child Process To Restart Post by: CrYpTiC_MauleR on January 28, 2008, 08:44:56 PM Code
I made this recurse function to apply any function to both the key and value of an array or just a string recursively. But for some reason when I use a multidimensional array it causes Firefox to say the following: "The connection to the server was reset while the page was loading." Checking the Apache error logs says this: [notice] Parent: child process exited with status 128 -- Restarting. I can't spot the logic problem with the function, is there an endless loop I don't see? If that is the case would Apache just not exhaust its resources opposed to having the child process terminate? Any insight on what could be causing this? Title: Re: Recurse Function Causing Apache Child Process To Restart Post by: VGR on February 02, 2008, 02:13:58 PM well, I tried it on my own server and I received quasi instanatly this answer :
___AAA______MMM___ I don't know if it's correct of not, but I didn't get any error nor infinite loop perhaps you could check out your server signature and compre it to mine : Apache/2.2.6 (Win32) PHP/5.2.5 Title: Re: Recurse Function Causing Apache Child Process To Restart Post by: CrYpTiC_MauleR on February 03, 2008, 08:59:10 AM You need to uncomment:
//$array = array('bbb'..... I put a test $array before to show that functions work without an array, the commented line is the one that when ran will cause the issue. Title: Re: Recurse Function Causing Apache Child Process To Restart Post by: VGR on February 04, 2008, 12:23:18 PM you sure have a problem. I got no dramatic error nor loop, but saw this :
PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to al locate 6944 bytes) in *.php on line 13 line 13 is your recurse() line : foreach ($data as $key => $value) add some tracing... Title: Re: Recurse Function Causing Apache Child Process To Restart Post by: GrandSchtroumpf on February 09, 2008, 07:09:38 PM This works...
I added a separate $data argument to the transform function. It simplifies the code. Code
Title: Re: Recurse Function Causing Apache Child Process To Restart Post by: CrYpTiC_MauleR on February 10, 2008, 07:55:54 PM I'll test the code when I get on my server, thanks.
Do you happen to know what the problem was? I still don't see what went wrong. Title: Re: Recurse Function Causing Apache Child Process To Restart Post by: rdivilbiss on February 10, 2008, 09:55:15 PM Off topic. Purse hook installed per request.
Title: Re: Recurse Function Causing Apache Child Process To Restart Post by: GrandSchtroumpf on February 15, 2008, 09:01:04 AM The problem in the original code is that your arrays are not built correctly.
You unset $args[0], then you create a new array that you pass to the recurse function: >> array(array($key => $value), $args) This is wrong... the resulting array is not what you need. It's an array with 2 entries: [ 0 ] : an array that contains your data. [ 1 ] : an array that contains your arguments. What you really need is this: [ 0 ] : data [ 1 ] : arg 1 [ 2 ] : arg 2 [ 3 ] : arg 3 ... [ n ] : arg n You could fix it using "array_merge", but there is a much simpler solution: Don't unset $args[0] and use "$args[0] = data". Another small problem is that you forgot to pass "$keys" to your recursion call. Bloody default argument values!!! Use them wisely... or don't use them at all. To simplify the code I also changed this: $new_data[$key] = (is_string($value)) ? call_user_func_array(...) : recurse(...); To this: $new_data[$key] = recurse(...); See fixed code here: Code
Powered by SMF 1.1 RC2 |
SMF © 2001-2005, Lewis Media
Joomla Bridge by JoomlaHacks.com |