Bug #75309 [Com]: Iterators are no longer alphabetical
| From: | james at bluebaytravel dot co dot uk | Date: | Thu, 05 Oct 2017 09:59:44 +0000 |
| Subject: | Bug #75309 [Com]: Iterators are no longer alphabetical | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211520@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75309&edit=1
ID: 75309
Comment by: james at bluebaytravel dot co dot uk
Reported by: james at bluebaytravel dot co dot uk
Summary: Iterators are no longer alphabetical
Status: Feedback
Type: Bug
Package: SPL related
Operating System: Ubuntu
PHP Version: 7.1.10
Block user comment: N
Private report: N
New Comment:
It's always been in order previously... I can't see an obvious reason as to why Ubuntu
would've changed the behaviour? I use Laravel Homestead and am able to go back to a prior
version and see the expected results.
Previous Comments:
------------------------------------------------------------------------
[2017-10-04 13:49:41] danack@php.net
What makes you think the order is guaranteed?
I'm pretty certain there is no code inside PHP to sort directory iterators internally, or for
any of the other filesystem functions.
The order of directory entries is controller by your underlying operating system, which is free to
return whatever order it feels like.
------------------------------------------------------------------------
[2017-10-04 13:33:56] james at bluebaytravel dot co dot uk
Description:
------------
In PHP 7.1.10 iterators are no longer iterating through results alphabetically.
PHP 7.1.8 is the last version I've been able to see the expected result on (I've not been
able to test anything later).
In our code, we have a folder with ,php files in there and two sub-folders (Api and Dashboard)
containing more .php files. In PHP 7.1.8 the test script iterators through them alphabetically but
in PHP 7.1.10 the Api sub-folder is listed at the end of the iterator.
Test script:
---------------
$directoryIterator = new RecursiveDirectoryIterator($path);
$routeIterator = new RecursiveIteratorIterator($directoryIterator);
$routes = new RegexIterator($routeIterator, '/^.+\.php$/i',
RecursiveRegexIterator::GET_MATCH);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75309&edit=1