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
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: domluc at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 22:01:36 2025 UTC