php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49900 RecursiveIteratorIterator fails when path variable contains folders name "root"
Submitted: 2009-10-16 13:21 UTC Modified: 2009-10-16 13:41 UTC
From: wloske at yahoo dot de Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.2.11 OS: Win XP SP2
Private report: No CVE-ID: None
 [2009-10-16 13:21 UTC] wloske at yahoo dot de
Description:
------------
The RecursiveIteratorIterator fails when the variable containing the path name to be traversed contains "root" anywhere.

Scanning a directory containing a folder named root works though.

1. Try the code, nothing should happen.
2. Rename the directory to "woot" and adjust the $basedir variabel
3. Restart the code. You should see a result
4. Make a directory like test and a directory inside named "root" with some content in it.
5. Adjust $basedir to point to the parent of "root", e.g. "e:\test"
6. Restart. You should see the contents of test including the folder "root".
7. Adjust $basedir to point to "root" itself, e.g. "E:\test\root"
8. Restart. You should see nothing


Reproduce code:
---------------
$basedir = realpath("E:\root");

echo "<html><body><pre>";

foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basedir, RecursiveDirectoryIterator::KEY_AS_PATHNAME), RecursiveIteratorIterator::CHILD_FIRST) as $file => $info) {
    if ($info->isDir()) {
    	//Directory
        echo "Dir:  ".$file."<br />";
    } else {
    	//File
    	echo "File: ".$file."<br />";
    	
    }
}
echo "</pre></body><html>";

Expected result:
----------------
A list of directories in the given path.

Actual result:
--------------
Nothing. Neither a listing nor an error. Just plain silence.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-16 13:35 UTC] colder@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

err, that's because \r is carriare return inside "" ?
 [2009-10-16 13:41 UTC] wloske at yahoo dot de
LOL ... I just figured that out myself ... stupid me ... I just should always use slash instead of backslash when typing paths ...

Sorry guys ... I just made a fool out of myself ;) ... I am still laughing ...

Is there a way to delete this piece of an "epic fail documentation" ;)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 09:01:30 2024 UTC