#39087 [NEW]: filetype() or is_dir() not recognizing a directory

From: Date: Mon, 09 Oct 2006 05:41:28 +0000
Subject: #39087 [NEW]: filetype() or is_dir() not recognizing a directory
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-103275@lists.php.net to get a copy of this message
From: scottayy at gmail dot com Operating system: Windows XP Pro SP2 Build 2600 PHP version: 5.1.6 PHP Bug Type: Directory function related Bug description: filetype() or is_dir() not recognizing a directory Description: ------------ PHP fails to recognize directories when looping through a directory. filetype() says lstat() fails, and is_dir() returns false. I have the following directory structure. / /themes/ /themes/crap/ /themes/default/ Using this simple script to loop through the themes directory and get directory names: Reproduce code: --------------- <?php //gather available themes function get_available_themes() { if($handle = @opendir('themes')) { $themes = array(); while(false !== ($file = readdir($handle))) { if(is_dir($file) && ($file != '.' && $file != '..')) { $themes[] = $file; } } if(empty($themes)) { return false; } } else { return false; } return $themes; } if($themes = get_available_themes()) { echo '<pre>'; print_r(get_available_themes()); echo '</pre>'; } else { echo 'No themes could be found.'; } ?> Expected result: ---------------- Array ( [0] => crap, [1] => default ) Actual result: -------------- The function returns false because the array actually contains: Array ( ) If I echo out $file during the while() loop, I see . .. crap default -- Edit bug report at http://bugs.php.net/?id=39087&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39087&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39087&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39087&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39087&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39087&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39087&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39087&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39087&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39087&r=support Expected behavior: http://bugs.php.net/fix.php?id=39087&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39087&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39087&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39087&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39087&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39087&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39087&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39087&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39087&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39087&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39087&r=mysqlcfg

« previous php.bugs (#103275) next »