Edit report at http://bugs.php.net/bug.php?id=51986&edit=1
ID: 51986 Updated by: [email protected] Reported by: daniel dot menard at ehesp dot fr Summary: array_filter breaks references when a callback is used -Status: Analyzed +Status: Closed Type: Bug Package: Arrays related Operating System: Windows XP PHP Version: 5.3.2 Assigned To: dmitry Block user comment: N Previous Comments: ------------------------------------------------------------------------ [2010-09-29 23:12:16] [email protected] The following patch has been added/updated: Patch Name: bug_51986_5_3 Revision: 1285794735 URL: http://bugs.php.net/patch-display.php?bug=51986&patch=bug_51986_5_3&revision=1285794735 ------------------------------------------------------------------------ [2010-09-29 23:11:41] [email protected] Sorry, it doesn't work on trunk, it works on my patched trunk :p Fixing bug #52940 would fix this. However, the patch for that bug has one effect that changes the current behavior of call_user_func_array (removes check for internal function) and another change when the refcount of the zval is <= 1 and it's a reference (a rare case). Attached a patch that changes as little as possible, yet fixes this bug. ------------------------------------------------------------------------ [2010-09-29 13:05:51] [email protected] Reproducible on PHP 5.3, but not on trunk. ------------------------------------------------------------------------ [2010-06-03 14:29:38] daniel dot menard at ehesp dot fr Thanks for your comment: your workaround works. However, having to redefine standard php functions like trim() or count() just to be able to use them with array_filter() is not very convenient, is it? The fact is that the function behaviour changed in a "revision release" which should not have broken my code... ;-) ------------------------------------------------------------------------ [2010-06-03 13:00:43] [email protected] Use a reference in your callback function: function my_trim(& $a) { return trim($a); } ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=51986 -- Edit this bug report at http://bugs.php.net/bug.php?id=51986&edit=1
