From: reiv4x at free dot fr
Operating system: Gentoo Linux
PHP version: 5.1.2
PHP Bug Type: SPL related
Bug description: RecursiveDirectoryIterator
Description:
------------
Hi!
I try this code but it's a strange result.
I don't receive same result for '.' directory.
Here is my directories structure :
# ll -R tmptest/
tmptest/:
total 12
-rw-r--r-- 1 apache apache 21 avr 6 15:56 tmpfile.txt
lrwxrwxrwx 1 apache apache 11 avr 6 15:56
tmplink.lnk -> tmpfile.txt
drwxr-xr-x 3 apache apache 4096 avr 6 15:56 tmpsubtest
drwxr-xr-x 2 apache apache 4096 avr 6 15:56 tmpsubtest2
tmptest/tmpsubtest:
total 4
drwxr-xr-x 2 apache apache 4096 avr 6 15:56
tmpsubsubtest
tmptest/tmpsubtest/tmpsubsubtest:
total 4
-rw-r--r-- 1 apache apache 21 avr 6 15:56 tmpfile.txt
tmptest/tmpsubtest2:
total 0
Reproduce code:
---------------
<?php
$rdi = new RecursiveDirectoryIterator('tmptest');
// -------- HERE CUT and PASTE X5 code bellow -------
echo '#############################<br />';
echo '__toString is = ['.$rdi.']<br />';
echo 'Current is = ['.$rdi->current().']<br />';
echo 'Key is = ['.$rdi->key().']<br />';
echo 'Valid is = ['.$rdi->valid().']<br />';
echo 'hasChildren is = ['.$rdi->hasChildren().']<br />';
$rdi->next();
// -------- HERE CUT and PASTE END -------
$rdi->rewind();
foreach ($rdi as $content) {
echo '++++++++++++++++++++++++++++++<br />';
echo '__toString is = ['.$rdi.']<br />';
echo 'Current is = ['.$rdi->current().']<br />';
echo 'Key is = ['.$rdi->key().']<br />';
echo 'Valid is = ['.$rdi->valid().']<br />';
echo 'hasChildren is = ['. $rdi->hasChildren().']<br />';
}
?>
Expected result:
----------------
#############################
__toString is = [tmpsubtest2]
Current is = [tmptest/tmpsubtest2]
Key is = [tmptest/tmpsubtest2]
Valid is = [1]
hasChildren is = [1]
#############################
__toString is = [tmpsubtest]
Current is = [tmptest/tmpsubtest]
Key is = [tmptest/tmpsubtest]
Valid is = [1]
hasChildren is = [1]
#############################
__toString is = [tmpfile.txt]
Current is = [tmptest/tmpfile.txt]
Key is = [tmptest/tmpfile.txt]
Valid is = [1]
hasChildren is = []
#############################
__toString is = [.tmpfilehidden.txt]
Current is = [tmptest/.tmpfilehidden.txt]
Key is = [tmptest/.tmpfilehidden.txt]
Valid is = [1]
hasChildren is = []
#############################
__toString is = [tmplink.lnk]
Current is = [tmptest/tmplink.lnk]
Key is = [tmptest/tmplink.lnk]
Valid is = [1]
hasChildren is = []
#############################
++++++++++++++++++++++++++++++
__toString is = [tmpsubtest2]
Current is = [tmptest/tmpsubtest2]
Key is = [tmptest/tmpsubtest2]
Valid is = [1]
hasChildren is = [1]
++++++++++++++++++++++++++++++
__toString is = [tmpsubtest]
Current is = [tmptest/tmpsubtest]
Key is = [tmptest/tmpsubtest]
Valid is = [1]
hasChildren is = [1]
++++++++++++++++++++++++++++++
__toString is = [tmpfile.txt]
Current is = [tmptest/tmpfile.txt]
Key is = [tmptest/tmpfile.txt]
Valid is = [1]
hasChildren is = []
++++++++++++++++++++++++++++++
__toString is = [.tmpfilehidden.txt]
Current is = [tmptest/.tmpfilehidden.txt]
Key is = [tmptest/.tmpfilehidden.txt]
Valid is = [1]
hasChildren is = []
++++++++++++++++++++++++++++++
__toString is = [tmplink.lnk]
Current is = [tmptest/tmplink.lnk]
Key is = [tmptest/tmplink.lnk]
Valid is = [1]
hasChildren is = []
Actual result:
--------------
In my result, these lines are add in first place.
I don't find '..' directory, only '.' and method
RecursiveDirectoryIterator::isDot() == True.
#############################
__toString is = [.]
Current is = [tmptest/.]
Key is = [tmptest/.]
Valid is = [1]
hasChildren is = []
--
Edit bug report at http://bugs.php.net/?id=36996&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36996&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36996&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36996&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36996&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36996&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36996&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36996&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36996&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36996&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36996&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36996&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36996&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36996&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36996&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36996&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36996&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36996&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36996&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36996&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36996&r=mysqlcfg