#40903 [NEW]: Weird array sorting problems in Apache module

From: Date: Fri, 23 Mar 2007 10:55:36 +0000
Subject: #40903 [NEW]: Weird array sorting problems in Apache module
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110722@lists.php.net to get a copy of this message
From: jan at horde dot org Operating system: Linux PHP version: 4CVS-2007-03-23 (CVS) PHP Bug Type: Arrays related Bug description: Weird array sorting problems in Apache module Description: ------------ This is a really weird edge case. See the unit test pasted below. If I run this test on the command line, it works fine. But if run the same test through the web server, the sorting simply doesn't happen. Apache is version 2.2.0. Passing the array through mysort() by reference is important, if I sort the array directly, everything is working fine. Reproduce code: --------------- --TEST-- uasort --FILE-- <?php $array = array( array('sort' => 'Horde (horde)'), array('sort' => 'E-Mail Mobil (mimp)'), array('sort' => 'Webmail Dynamisch (dimp)')); function mysort(&$array) { uasort($array, create_function('$a, $b', '$cmp = strcoll(strtolower($a["sort"]), strtolower($b["sort"])); var_dump($a["sort"], $b["sort"], $cmp); return $cmp;')); } mysort($array); var_dump($array); ?> --EXPECT-- string(19) "E-Mail Mobil (mimp)" string(13) "Horde (horde)" int(-1) string(24) "Webmail Dynamisch (dimp)" string(19) "E-Mail Mobil (mimp)" int(1) string(13) "Horde (horde)" string(19) "E-Mail Mobil (mimp)" int(1) string(24) "Webmail Dynamisch (dimp)" string(13) "Horde (horde)" int(1) array(3) { [1]=> array(1) { ["sort"]=> string(19) "E-Mail Mobil (mimp)" } [0]=> array(1) { ["sort"]=> string(13) "Horde (horde)" } [2]=> array(1) { ["sort"]=> string(24) "Webmail Dynamisch (dimp)" } } Actual result: -------------- Result if run through apache: string(19) "E-Mail Mobil (mimp)" string(13) "Horde (horde)" int(-1) string(24) "Webmail Dynamisch (dimp)" string(19) "E-Mail Mobil (mimp)" int(1) string(13) "Horde (horde)" string(19) "E-Mail Mobil (mimp)" int(1) string(24) "Webmail Dynamisch (dimp)" string(13) "Horde (horde)" int(1) array(3) { [0]=> array(1) { ["sort"]=> string(13) "Horde (horde)" } [1]=> array(1) { ["sort"]=> string(19) "E-Mail Mobil (mimp)" } [2]=> array(1) { ["sort"]=> string(24) "Webmail Dynamisch (dimp)" } } -- Edit bug report at http://bugs.php.net/?id=40903&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40903&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40903&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40903&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40903&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40903&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40903&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40903&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40903&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40903&r=support Expected behavior: http://bugs.php.net/fix.php?id=40903&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40903&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40903&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40903&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40903&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40903&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40903&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40903&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40903&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40903&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40903&r=mysqlcfg

« previous php.bugs (#110722) next »