Edit report at https://bugs.php.net/bug.php?id=64533&edit=1

 ID:                 64533
 Updated by:         paj...@php.net
 Reported by:        kasper at webmasteren dot eu
 Summary:            recursive iterator makes dir become file
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            SPL related
 Operating System:   Windows 8 x64
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Is it only:

$f = new \SplFileInfo("pages\\a\\main");
var_dump($f->isDir()); //SHOULD BE TRUE!

that fails? Or previous calls fail too? Inside the foreach.

Also if you could provide a script that creates the structure and reproduce the 
bug, that would make the debugging session easier.


Previous Comments:
------------------------------------------------------------------------
[2013-03-27 13:37:06] kasper at webmasteren dot eu

Description:
------------
It is possible for the following code , to change a FOLDER to a "file", by 
SPL's 
functions, which only from what i have seen occures by the recursive itterator.

all there is needed is a folder structure like:
pages/a
       /main
       /main.top
       /main.content
       /main.menu

and those folders all have at least a file, in my particular case, "view.php".
The example, even prints what the old standard functions tell about the "path" 
from the element, and what the spl provides. 

Test script:
---------------
$recursiveIterator = new \RecursiveIteratorIterator(new 
\RecursiveDirectoryIterator("pages\\a", 
\RecursiveDirectoryIterator::SKIP_DOTS), 
\RecursiveIteratorIterator::CHILD_FIRST);
foreach ($recursiveIterator as $element) { //the child first => top lvl first.
    var_dump("path:" . $element->getPath());

    if ($element->isFile()) {
        var_dump("Is file by new function(SPL)");
    }
    if($element->isDir()){
        var_dump("is dir by new function");
    }

    if (\is_dir($element->getPath())) {
        var_dump("Is dir by old function");
    }
    
    if(\is_file($element->getPath())){
        var_dump("is file by old function");
    }
}
$f = new \SplFileInfo("pages\\a\\main");
var_dump($f->isDir()); //SHOULD BE TRUE!!

Expected result:
----------------
that SPL and the old functions would agree, and folders were reportet as 
folders.

Actual result:
--------------
That in SPL , inside of Recursive iterator and possibly 
recursiveDirectoryIterator 
folders becomes seen as files, causing it to report wrong type (only spl, not 
the 
old functions).



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64533&edit=1

Reply via email to