Edit report at https://bugs.php.net/bug.php?id=62433&edit=1
ID: 62433 Updated by: larue...@php.net Reported by: miau dot jp at gmail dot com Summary: Inconsistent behavior of RecursiveDirectoryIterator to dot files (. and ..) -Status: Open +Status: Closed Type: Bug Package: SPL related Operating System: All PHP Version: 5.4.4 -Assigned To: +Assigned To: laruence Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2012-07-02 03:34:02] larue...@php.net Automatic comment on behalf of laruence Revision: http://git.php.net/?p=php-src.git;a=commit;h=be4053cea0462c9de5396641f4e4fa2f56f5a675 Log: Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to dot files). ------------------------------------------------------------------------ [2012-07-02 03:33:13] larue...@php.net Automatic comment on behalf of laruence Revision: http://git.php.net/?p=php-src.git;a=commit;h=be4053cea0462c9de5396641f4e4fa2f56f5a675 Log: Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to dot files). ------------------------------------------------------------------------ [2012-06-27 17:59:11] miau dot jp at gmail dot com Description: ------------ RecurisveDirectoryIterator skips dot files (. and ..) that appear on the top of directory entries only. Since some file systems (e.g.: ext3, FAT32) doesn't sort directory entries, the behavior of RecursiveDirectoryIterator is inconsistent. RecursiveDirectoryIterator should either always skip dot files, or never skip dot files. Otherwise many developer mistakenly assume that RecurisveDirectoryIterator always skips dot files, and add a bug to their programs. ---- (tested on ext3 file system) # mkdir test # cd test # cat <<\EOF >test.php <?php echo __DIR__ . "\n"; print_r(array_keys(iterator_to_array( new RecursiveDirectoryIterator(__DIR__) ))); EOF (use "-U" option not to sort) # ls -liaU total 16 8314945 drwxr-x--- 8 root root 4096 6æ 28 02:15 .. 8315727 drwxr-xr-x 2 root root 4096 6æ 28 02:16 . 8315728 -rw-r--r-- 1 root root 114 6æ 28 02:16 test.php # php test.php /root/test Array ( [0] => /root/test/test.php ) # touch 1 2 3 4 5 # ls -liaU total 16 8315730 -rw-r--r-- 1 root root 0 6æ 28 02:16 2 8315733 -rw-r--r-- 1 root root 0 6æ 28 02:16 5 8314945 drwxr-x--- 8 root root 4096 6æ 28 02:15 .. 8315727 drwxr-xr-x 2 root root 4096 6æ 28 02:16 . 8315728 -rw-r--r-- 1 root root 114 6æ 28 02:16 test.php 8315729 -rw-r--r-- 1 root root 0 6æ 28 02:16 1 8315731 -rw-r--r-- 1 root root 0 6æ 28 02:16 3 8315732 -rw-r--r-- 1 root root 0 6æ 28 02:16 4 # php test.php /root/test Array ( [0] => /root/test/2 [1] => /root/test/5 [2] => /root/test/.. [3] => /root/test/. [4] => /root/test/test.php [5] => /root/test/1 [6] => /root/test/3 [7] => /root/test/4 ) (To ensure skippping dot files, construct the RecursiveDirectoryIterator with SKIP_DOTS flag for now.) # cat <<\EOF >test.php <?php echo __DIR__ . "\n"; print_r(array_keys(iterator_to_array( new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS) ))); EOF # php test.php /root/test Array ( [0] => /root/test/2 [1] => /root/test/5 [2] => /root/test/test.php [3] => /root/test/1 [4] => /root/test/3 [5] => /root/test/4 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62433&edit=1