Bug #68897 [NEW]: Using variable for sort flag in array_multisort cause wrong results

From: Date: Sat, 24 Jan 2015 05:51:14 +0000
Subject: Bug #68897 [NEW]: Using variable for sort flag in array_multisort cause wrong results
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190169@lists.php.net to get a copy of this message
From: jrbasso at gmail dot com Operating system: Linux PHP version: master-Git-2015-01-24 (Git) Package: Arrays related Bug Type: Bug Bug description:Using variable for sort flag in array_multisort cause wrong results Description: ------------ Using master rev. be5337421680f059f7b23dd530645e070b15715a the array_multisort have incorrect behavior if the SORT direction flag is passed in a variable. This behavior is ok on HHVM and until PHP 5.6. See http://3v4l.org/7pU0u Test script: --------------- // Works $values = array("Lindsay", "Nate"); array_multisort($values, SORT_DESC, SORT_REGULAR, array(0, 1), SORT_DESC, SORT_REGULAR); var_dump($values); // Doesn't work $values = array("Lindsay", "Nate"); $dir = SORT_DESC; array_multisort($values, $dir, SORT_REGULAR, array(0, 1), $dir, SORT_REGULAR); var_dump($values); Expected result: ---------------- array(2) { [0]=> string(4) "Nate" [1]=> string(7) "Lindsay" } array(2) { [0]=> string(4) "Nate" [1]=> string(7) "Lindsay" } Actual result: -------------- array(2) { [0]=> string(4) "Nate" [1]=> string(7) "Lindsay" } array(2) { [0]=> string(7) "Lindsay" [1]=> string(4) "Nate" } -- Edit bug report at https://bugs.php.net/bug.php?id=68897&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68897&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68897&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68897&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68897&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68897&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68897&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68897&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68897&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68897&r=support Expected behavior: https://bugs.php.net/fix.php?id=68897&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68897&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68897&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68897&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68897&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68897&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68897&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68897&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68897&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68897&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68897&r=mysqlcfg

« previous php.bugs (#190169) next »