ID: 45700 User updated by: j dot jeising at gmail dot com Reported By: j dot jeising at gmail dot com Status: Bogus Bug Type: Arrays related Operating System: * PHP Version: 5.2.6 New Comment:
Year, cool way to solve problems - "Exists long enough to not be a bug(, for all unbelievers add an error to the next version." But the problem still exists - why should I only use the function with long values? Why not for arrays or other types? I can tell you: the way in this case was the following: 1. (4.0.5) Add PHP function array_reduce, need something to implement some mathematical operations 2. (5.0.1) Some changed behaviours in PHP 5 cause a segfault if an array is passed, let's convert it to long, according to the orignal target. Oh and change the docs, it takes a int instead of mixed as last parameter. 3. (5.3) Let's clean everything up, we throw errors in other functions with types, let's do it here, too. => The problem is, that the original segfault is not realy fixed. Perhaps it's already solved in PHP 5.3 (so you only have to remove the conversion code), perhaps not. But this is not a bogus, it's not the goal of the function, it's simply a bad fixed bug and it's story. So please change status back to Open (/Feature Request) and fix it! Previous Comments: ------------------------------------------------------------------------ [2008-08-04 21:26:54] [EMAIL PROTECTED] Using PHP 5.3: Warning: array_reduce() expects parameter 3 to be long, array given in /usr/src/build/php_5_3CVS_tst/t.php on line 10 Current behaviour in 5.2 has existed long enough not to be broken in PHP 5.2 branch. ------------------------------------------------------------------------ [2008-08-03 14:18:26] j dot jeising at gmail dot com Description: ------------ array_reduce only accepts integer as the $initial value. All other values are converted to long. This problem was already discussed in #42566, but the only answer is thats because of a fix to #29954. The fix for #29954 was the following change: if (ZEND_NUM_ARGS() > 2) { convert_to_long_ex(initial); result = *initial; } http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/array.c?r1=1.283&r2=1.284 That's not a proper fix to the problem. You can't solve a segfault with a type conversion - some functionality is missing here. Reproduce code: --------------- $array = array ( array ( 1 ), array ( 2 ) ); print_r ( array_reduce ( $array, 'array_merge', array ( ) ); Expected result: ---------------- Array ( [0] => 1, [1] => 2 ); Actual result: -------------- Warning: array_merge() [function.array-merge]: Argument #1 is not an array in test.php on line 3 => initial value is 1. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45700&edit=1