php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60933 Testing asort with SORT_LOCALE_STRING fails on Mac OS X 10.6
Submitted: 2012-01-30 13:50 UTC Modified: 2012-02-03 04:17 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mgdm@php.net Assigned: aharvey (profile)
Status: Closed Package: Arrays related
PHP Version: 5.4SVN-2012-01-30 (SVN) OS: Mac OS X 10.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mgdm@php.net
New email:
PHP Version: OS:

 

 [2012-01-30 13:50 UTC] mgdm@php.net
Description:
------------
The test ext/standard/tests/array/locale_sort.phpt fails. "Île-du-Prince-Édouard" 
is sorted to the end of the array, instead of the expected 3rd position.

Test script:
---------------
<?php                                                                           
setlocale(LC_ALL, 'fr_FR', 'fr_FR.ISO8859-1');                                  
$table = array("AB" => "Alberta",                                               
"BC" => "Colombie-Britannique",                                                 
"MB" => "Manitoba",                                                             
"NB" => "Nouveau-Brunswick",                                                    
"NL" => "Terre-Neuve-et-Labrador",                                              
"NS" => "Nouvelle-Écosse",                                                      
"ON" => "Ontario",                                                              
"PE" => "Île-du-Prince-Édouard",                                                
"QC" => "Québec",                                                               
"SK" => "Saskatchewan",                                                         
"NT" => "Territoires du Nord-Ouest",                                            
"NU" => "Nunavut",                                                              
"YT" => "Territoire du Yukon");                                                 
asort($table, SORT_LOCALE_STRING);                                              
var_dump($table);

Expected result:
----------------
array(13) {                                                                     
  ["AB"]=>                                                                      
  string(7) "Alberta"                                                           
  ["BC"]=>                                                                      
  string(20) "Colombie-Britannique"                                             
  ["PE"]=>                                                                      
  string(21) "Île-du-Prince-Édouard"                                            
  ["MB"]=>                                                                      
  string(8) "Manitoba"                                                          
  ["NB"]=>                                                                      
  string(17) "Nouveau-Brunswick"                                                
  ["NS"]=>                                                                      
  string(15) "Nouvelle-Écosse"                                                  
  ["NU"]=>                                                                      
  string(7) "Nunavut"                                                           
  ["ON"]=>                                                                      
  string(7) "Ontario"                                                           
  ["QC"]=>                                                                      
  string(6) "Québec"                                                            
  ["SK"]=>                                                                      
  string(12) "Saskatchewan"                                                     
  ["NL"]=>                                                                      
  string(23) "Terre-Neuve-et-Labrador"                                          
  ["YT"]=>                                                                      
  string(19) "Territoire du Yukon"                                              
  ["NT"]=>                                                                      
  string(25) "Territoires du Nord-Ouest"

Actual result:
--------------
array(13) {                                                                                                                                                                                                        
  ["AB"]=>                                                                      
  string(7) "Alberta"                                                           
  ["BC"]=>                                                                      
  string(20) "Colombie-Britannique"                                             
  ["MB"]=>                                                                      
  string(8) "Manitoba"                                                          
  ["NB"]=>                                                                      
  string(17) "Nouveau-Brunswick"                                                
  ["NS"]=>                                                                      
  string(15) "Nouvelle-Écosse"                                                  
  ["NU"]=>                                                                      
  string(7) "Nunavut"                                                           
  ["ON"]=>                                                                      
  string(7) "Ontario"                                                           
  ["QC"]=>                                                                      
  string(6) "Québec"                                                            
  ["SK"]=>                                                                      
  string(12) "Saskatchewan"                                                     
  ["NL"]=>                                                                      
  string(23) "Terre-Neuve-et-Labrador"                                          
  ["YT"]=>                                                                      
  string(19) "Territoire du Yukon"                                              
  ["NT"]=>                                                                      
  string(25) "Territoires du Nord-Ouest"                                        
  ["PE"]=>                                                                      
  string(21) "Île-du-Prince-Édouard"                                            
} 

Patches

bug-60933-locale-sort-test (last revision 2012-02-02 04:50 UTC by aharvey@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-01 03:58 UTC] carloschilazo at gmail dot com
I think this goes waaay back to: 41758

And bug 41758 is in status Won't fix, I couldn't find why.

Is there a reason behind this?

Thanks
 [2012-02-01 13:03 UTC] fa@php.net
Works on FreeBSD 8.2-RELEASE with snap php5.4-201202011030

PASS Sort with SORT_LOCALE_STRING [ext/standard/tests/array/locale_sort.phpt]
 [2012-02-01 16:32 UTC] rasmus@php.net
Bug 41758 is a won't fix simply because it is against PHP6 and we aren't fixing 
bugs in that dead branch at this point. This also a different issue since this 
one appears to be OSX-specific. This same test passes nicely on various versions 
of Debian and Ubuntu Linux.
 [2012-02-01 17:49 UTC] carloschilazo at gmail dot com
I think its not related to MAC OSX, test failed php5.4-201202011630 ubuntu 11.10
 [2012-02-01 19:32 UTC] rasmus@php.net
I just ran it on an Ubuntu 11.10 box and it passed. So then it is environment-
specific somehow.
 [2012-02-02 00:55 UTC] j dot jeising at gmail dot com
Only failed test for me too (Mac OS X 10.6.8). Any environment specific details we 
could provide to reproduce this? (LANG="de_DE.UTF-8", LC_CTYPE="en_US.UTF-8")
 [2012-02-02 04:50 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: aharvey
 [2012-02-02 04:50 UTC] aharvey@php.net
I think this may just be nothing more than the default fr_FR locale selected on OS 
X nowadays simply being UTF-8 by default these days, which obviously fails to sort 
an ISO-8859-1 array correctly.

Can people who've had this fail try the attached patch and see if it fixes the 
problem, please?
 [2012-02-02 04:50 UTC] aharvey@php.net
The following patch has been added/updated:

Patch Name: bug-60933-locale-sort-test
Revision:   1328158259
URL:        https://bugs.php.net/patch-display.php?bug=60933&patch=bug-60933-locale-sort-test&revision=1328158259
 [2012-02-02 14:18 UTC] j dot jeising at gmail dot com
Patch fixed the problem, test passes.
 [2012-02-02 15:29 UTC] rasmus@php.net
Looks good, commit.
 [2012-02-03 01:21 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=323036
Log: Fix bug #60933 (Testing asort with SORT_LOCALE_STRING fails on Mac OS X 10.6) on PHP_5_3 and trunk.
 [2012-02-03 01:21 UTC] aharvey@php.net
-Status: Assigned +Status: Suspended
 [2012-02-03 01:21 UTC] aharvey@php.net
Fixed on trunk and 5.3. Pinging stas and dsp re: 5.4.
 [2012-02-03 04:17 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=323037
Log: Fix bug #60933 on PHP_5_4 (approved by Stas).
 [2012-02-03 04:17 UTC] aharvey@php.net
-Status: Suspended +Status: Closed
 [2012-02-03 04:17 UTC] aharvey@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Fixed on 5.4 as well, per private e-mail with Stas.
 [2012-04-18 09:46 UTC] laruence@php.net
Automatic comment on behalf of aharvey
Revision: http://git.php.net/?p=php-src.git;a=commit;h=325ca60fa7586bd387a9a65653bce3761393dabe
Log: Fix bug #60933 (Testing asort with SORT_LOCALE_STRING fails on Mac OS X 10.6) on PHP_5_3 and trunk.
 [2012-07-24 23:37 UTC] rasmus@php.net
Automatic comment on behalf of aharvey
Revision: http://git.php.net/?p=php-src.git;a=commit;h=325ca60fa7586bd387a9a65653bce3761393dabe
Log: Fix bug #60933 (Testing asort with SORT_LOCALE_STRING fails on Mac OS X 10.6) on PHP_5_3 and trunk.
 [2013-11-17 09:34 UTC] laruence@php.net
Automatic comment on behalf of aharvey
Revision: http://git.php.net/?p=php-src.git;a=commit;h=325ca60fa7586bd387a9a65653bce3761393dabe
Log: Fix bug #60933 (Testing asort with SORT_LOCALE_STRING fails on Mac OS X 10.6) on PHP_5_3 and trunk.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 21:01:34 2025 UTC