php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48881 RecursiveDirectoryIterator bring file list in wrong order according to so
Submitted: 2009-07-10 19:49 UTC Modified: 2009-07-10 21:49 UTC
From: domluc at gmail dot com Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.2.10 OS: Linux ws63 2.6.24-24-generic #1
Private report: No CVE-ID: None
 [2009-07-10 19:49 UTC] domluc at gmail dot com
Description:
------------
Working with RecursiveDirectoryIterator bring a weird order in differrent machines.

if I had a directory with two files:
test1.ext
test2.ext

in some installs the order will be
test1.ext
test2.ext

and in anothers will be
test2.ext
test1.ext

the main problem is that I can't trust in result, so the goal is iterator guarantee a certain order in all 


Reproduce code:
---------------
# you must create a 'test_data_fixtures' dir
# and put two files there test2.yml test1.yml

$dir = 'test_data_fixtures';
$it = new RecursiveDirectoryIterator($dir, RecursiveIteratorIterator::LEAVES_ONLY);                                                            
foreach ($it as $file) {
  echo "File: " . $file . "\n";
}

Expected result:
----------------
File: test_data_fixtures/test1.yml
File: test_data_fixtures/test2.yml

Actual result:
--------------
File: test_data_fixtures/test2.yml
File: test_data_fixtures/test1.yml

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-10 21:49 UTC] jani@php.net
See bug #45634 for explanation. And never ever submit a bug report 
without searching the existing reports first.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC