From: kasper at webmasteren dot eu
Operating system: Windows 8 x64
PHP version: Irrelevant
Package: SPL related
Bug Type: Bug
Bug description:recursive iterator makes dir become file
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 bug report at https://bugs.php.net/bug.php?id=64533&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64533&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64533&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64533&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64533&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64533&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64533&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64533&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64533&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64533&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64533&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64533&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64533&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64533&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64533&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64533&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64533&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64533&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64533&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64533&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64533&r=mysqlcfg