|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2010-08-27 22:42 UTC] apouch at woozworld dot com
 Description:
------------
This is something that changed between PHP 5.3.2 and PHP 5.3.3.
array_walk_recursive accepts a 3rd parameter for 'userdata'.
If:
- this parameter is an object AND
- the user-created function used as second parameter to array_walk_recursive defines the third parameter by reference AND
- The array given as first parameter to array_walk_recursive is a multi-dimensional array,
PHP crashes.
Test script:
---------------
$array = array('foo', 'bar' => array('taz'));
$foo = new stdClass();
array_walk_recursive($array, create_function('&$v, $k, &$u', ''), $foo);
echo 'No crash';
//This one works: array_walk_recursive($array, create_function('&$v, $k, $u', ''), $foo);
Expected result:
----------------
No Crash
Actual result:
--------------
PHP crashes
Patchesarray_walk_recursive.patch (last revision 2012-01-27 13:06 UTC by nikic@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 01:00:01 2025 UTC | 
This is still a problem with PHP 5.3.4. Strange is that it segfaults after the call to array_walk_recursive; running is printed. See this test script, which segfaults: <?php $array = array("hello", array("bye")); $flat = array(); array_walk_recursive($array, function (&$value, $key, &$flat) { $flat[] = $value; }, $flat); echo "Running";