php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40903 yunosh
Submitted: 2007-03-23 10:55 UTC Modified: 2007-04-13 09:32 UTC
From: jan at horde dot org Assigned: derick (profile)
Status: Closed Package: Arrays related
PHP Version: 4CVS-2007-03-23 (CVS) OS: Linux
Private report: No CVE-ID: None
 [2007-03-23 10:55 UTC] 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)"
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-26 23:31 UTC] tony2001@php.net
Tested with Apache 2 worker/mpm and latest CVS.
Cannot replicate.
 [2007-03-26 23:33 UTC] tony2001@php.net
"worker/mpm" should be read as "worker/prefork".

 [2007-03-27 11:26 UTC] jan at horde dot org
Using worker/prefork here too. Derick, can you reproduce it? Is there anything else I could try to track this down?
 [2007-04-13 09:32 UTC] jan at horde dot org
Looks like this has been solved with 4.4.7-RC1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 17:01:33 2024 UTC