#37070 [NEW]: SplFileObject::isDir() returns false for empty dirs

From: Date: Thu, 13 Apr 2006 12:19:28 +0000
Subject: #37070 [NEW]: SplFileObject::isDir() returns false for empty dirs
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95746@lists.php.net to get a copy of this message
From: pornel at despammed dot com Operating system: OS X PHP version: 6CVS-2006-04-13 (snap) PHP Bug Type: SPL related Bug description: SplFileObject::isDir() returns false for empty dirs Description: ------------ I'm using RecursiveDirectoryIterator to scan directories. File objects returned by this iterator seem to threat isDir and hasChildren as the same thing. That is isDir returns true only when item has children. This assumption is invalid and causes empty directories to be reported as files. Reproduce code: --------------- <?php function scan(RecursiveDirectoryIterator $dir) { foreach($dir as $file) { var_dump($file->isDir()); if ($dir->hasChildren()) scan($dir->getChildren()); } } scan(new RecursiveDirectoryIterator('/some/path/that/has/empty/dirs')); Expected result: ---------------- isDir should not act as alias of hasChildren Actual result: -------------- empty directories have isFile()==true and isDir()==false -- Edit bug report at http://bugs.php.net/?id=37070&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37070&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37070&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37070&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37070&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37070&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37070&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37070&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37070&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37070&r=support Expected behavior: http://bugs.php.net/fix.php?id=37070&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37070&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37070&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37070&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37070&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37070&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37070&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37070&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37070&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37070&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37070&r=mysqlcfg

« previous php.bugs (#95746) next »