From:             j dot jeising at gmail dot com
Operating system: all
PHP version:      5.2.6
PHP Bug Type:     Arrays related
Bug description:  array_reduce only accepts integer as $initial

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 bug report at http://bugs.php.net/?id=45700&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45700&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45700&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45700&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45700&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45700&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45700&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45700&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45700&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45700&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45700&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45700&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45700&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45700&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45700&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45700&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45700&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45700&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45700&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45700&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45700&r=mysqlcfg

Reply via email to