Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.6.0a3

Request #9659 The userdata parameter isn't correctly send to the recursive call
Submitted: 2006-12-19 17:44 UTC
From: jean-philippe dot goydadin at rve dot ulaval dot ca Assigned: arpad
Status: Closed Package: PHP_Compat (version 1.5.0)
PHP Version: 4.4.4 OS: Windows
Roadmaps: 1.6.0a1    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 8 + 3 = ?

 
 [2006-12-19 17:44 UTC] jean-philippe dot goydadin at rve dot ulaval dot ca (jipolin)
Description: ------------ Why the recursive call of array_walk_recursive() doesn't the exact parameter it needs ? The first and second arguments are OK ($item and $funcname) but the third give the complete array , so the function receive $item and $funcname and an array containing $item, $funcname and the $userdata variable. Then in the funcname function, if you use the $userdata parameter, you have to think that the parameters is the array and the $userdata is the third value of this array ! Test script: --------------- // Line 56 of the code in the 1.7 version // array_walk_recursive($item, $funcname, $args); // My proposition // array_walk_recursive($item, $funcname, $args[2]); // function to call function test_userdata(&$item, $key, $userdata) { $item = $userdata . ' - ' . $item; } $a = array(array('test11', 'test12', 'test13'), 'test2', array('test31', 'test32')); array_walk_recursive($a, 'test_userdata', 'print userdata'); print_r($a); Expected result: ---------------- Array ( [0] => Array ( [0] => print userdata - test11 [1] => print userdata - test12 [2] => print userdata - test13 ) [1] => print userdata - test2 [2] => Array ( [0] => print userdata - test31 [1] => print userdata - test32 ) ) Actual result: -------------- Array ( [0] => Array ( [0] => Array - test11 [1] => Array - test12 [2] => Array - test13 ) [1] => print userdata - test2 [2] => Array ( [0] => Array - test31 [1] => Array - test32 ) )

Comments

 [2007-04-06 17:00 UTC] arpad (Arpad Ray)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.