From:             weierophin...@php.net
Operating system: Ubuntu 9.04
PHP version:      5.3.0
PHP Bug Type:     Arrays related
Bug description:  regression in array_mulitsort()

Description:
------------
Prior to 5.3.0, array_multisort() expected no references; the last array
provided would be assumed to be a reference, and updated by the function
during processing.

Starting in 5.3.0, array_multisort() now expects all arguments to be
passed by reference, raising a warning if it detects any are passed by
copy. This also includes the various sort flags (which simply does not make
sense, since the SORT_* constants are typically passed directly).

In the reproduce code below, if you pass all arguments by reference, you
get the expected result. However, this is a BC break from previous versions
of PHP, as you were not required to pass by reference.

An additional BC break occurs with the results: if you ignore the warning,
the results returned differ from what was returned prior to 5.3 (this is
shown below). You will only get the expected results if, again, all
arguments are passed by reference.

Reproduce code:
---------------
$array1 = array('foo', 'bar', 'baz');
$array2 = array('baz', 'bar', 'foo');
$array3 = array('Foo', 'Bar', 'Baz');
$sort1a  = SORT_ASC;
$sort1b  = SORT_STRING;
$sort2a  = SORT_ASC;
$sort2b  = SORT_REGULAR;

$args = array($array1, $sort1a, $sort1b, $array2, $sort2a, $sort2b,
&$array3);
call_user_func_array('array_multisort', $args);
var_export($array3);


Expected result:
----------------
array (
  0 => 'Bar',
  1 => 'Baz',
  2 => 'Foo',
)

Actual result:
--------------
Warning: Parameter 1 to array_multisort() expected to be a reference,
value given in /home/matthew/tmp/test.php on line 23
array (
  0 => 'Foo',
  1 => 'Bar',
  2 => 'Baz',
)

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

Reply via email to