#40903 [Opn->Asn]: Weird array sorting problems in Apache module

From: Date: Mon, 26 Mar 2007 23:20:25 +0000
Subject: #40903 [Opn->Asn]: Weird array sorting problems in Apache module
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110827@lists.php.net to get a copy of this message
ID: 40903 Updated by: tony2001@php.net Reported By: jan at horde dot org -Status: Open +Status: Assigned Bug Type: Arrays related Operating System: Linux PHP Version: 4CVS-2007-03-23 (CVS) -Assigned To: +Assigned To: derick Previous Comments: ------------------------------------------------------------------------ [2007-03-23 10:55:36] jan at horde dot org 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 this bug report at http://bugs.php.net/?id=40903&edit=1

« previous php.bugs (#110827) next »