php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65709 Sorting an array gives different outputs when intl is enabled
Submitted: 2013-09-19 11:54 UTC Modified: 2016-04-24 04:22 UTC
Votes:7
Avg. Score:4.9 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:6 (85.7%)
Same OS:5 (71.4%)
From: info at arnoldpistorius dot com Assigned:
Status: No Feedback Package: intl (PECL)
PHP Version: 5.5.3 OS: CENTOS 6.3
Private report: No CVE-ID: None
 [2013-09-19 11:54 UTC] info at arnoldpistorius dot com
Description:
------------
I am trying to sort an array containing file names with SORT_LOCALE_STRING. 
However the result is not consistent when I refresh the page several times. It 
appears to be that the output randomly differs.

This behaviour is only occuring when PHP is compiled with intl (--enable-intl) or 
the pecl extension intl is installed. I foudn this out when I was experiencing 
different behaviour on scandir, which does also a sort.

You can reproduce the problem by executing the following script several times by 
pressing F5 in your browser.

Test script:
---------------
<?php
setlocale(LC_ALL, 'NL_nl');
$files = array('__Abstract.js', '__Abstract.coffee', 'Delete.js', 'Delete.coffee', 'Copy.js', 'Copy.coffee');

sort($files, SORT_LOCALE_STRING);
var_dump($files);
?>

Expected result:
----------------
The script should always have the same output

Actual result:
--------------
 Most of the times I get the following output:

array (
  0 => '.',
  1 => '..',
  2 => '__Abstract.coffee',
  3 => '__Abstract.js',
  4 => 'Copy.coffee',
  5 => 'Copy.js',
  6 => 'Delete.coffee',
  7 => 'Delete.js',
)

But now and then the output is:

array (
  0 => '.',
  1 => '..',
  2 => 'Copy.coffee',
  3 => 'Copy.js',
  4 => 'Delete.coffee',
  5 => 'Delete.js',
  6 => '__Abstract.coffee',
  7 => '__Abstract.js',
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-19 12:00 UTC] info at arnoldpistorius dot com
-: info at arnoldpistoirus dot com +: info at arnoldpistorius dot com
 [2013-09-19 12:00 UTC] info at arnoldpistorius dot com
Corrected e-mail address typo
 [2016-04-12 13:27 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-04-12 13:27 UTC] ab@php.net
Thanks for the report. I don't reproduce the random sort issue with your snippet. Furthermore, the actual result looks different from what it should output. Please provide a reliable snippet for this.

Thanks.
 [2016-04-24 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 16:01:26 2024 UTC