From:             miau dot jp at gmail dot com
Operating system: All
PHP version:      5.4.4
Package:          SPL related
Bug Type:         Bug
Bug description:Inconsistent behavior of RecursiveDirectoryIterator to dot 
files (. and ..)

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 bug report at https://bugs.php.net/bug.php?id=62433&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62433&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62433&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62433&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62433&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62433&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62433&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62433&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62433&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62433&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62433&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62433&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62433&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62433&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62433&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62433&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62433&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62433&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62433&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62433&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62433&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62433&r=mysqlcfg

Reply via email to