From: andy dot shellam at mailnetwork dot co dot uk Operating system: Fedora Core 5 PHP version: 5.1.4 PHP Bug Type: Directory function related Bug description: is_dir only returns TRUE on . and ..
Description: ------------ Running is_dir on an array of files returned from scandir, only returns TRUE on the "." and ".." directories. Actually, is_dir returns nothing on anything except "." and "..". I notice an extremely old bug #5693 had the same issue. Reproduce code: --------------- <?php function SwitchRC($code) { if ($code == 1) { return "TRUE"; } else { return "FALSE"; } } $Files = scandir("/"); for ($intC = 0; $intC < count($Files); $intC++) { echo $Files[$intC] . " = " . SwitchRC(is_dir($Files[$intC])) . "\n"; } ?> Expected result: ---------------- . = TRUE .. = TRUE .autofsck = TRUE bin = TRUE boot = TRUE dev = TRUE endeavour = TRUE etc = TRUE home = TRUE lib = TRUE lost+found = TRUE media = TRUE misc = TRUE mnt = TRUE net = TRUE opt = TRUE proc = TRUE root = TRUE sbin = TRUE selinux = TRUE srv = TRUE sys = TRUE test_text_file = FALSE tmp = TRUE usr = TRUE var = TRUE (test_text_file) is a file, everything else is a directory, as shown by the "ls -l /" output: total 168 drwxr-xr-x 2 root root 4096 Jun 22 02:20 bin drwxr-xr-x 3 root root 4096 Jun 19 19:19 boot drwxr-xr-x 9 root root 3600 Jun 22 19:17 dev drwxrwxr-x 9 root dataHandler 4096 Jun 25 01:29 endeavour drwxr-xr-x 88 root root 12288 Jun 24 16:06 etc drwxr-xr-x 7 root root 4096 Jun 21 22:39 home drwxr-xr-x 11 root root 4096 Jun 21 19:14 lib drwx------ 2 root root 16384 Jun 19 20:02 lost+found drwxr-xr-x 2 root root 4096 Feb 11 17:16 media drwxr-xr-x 2 root root 4096 Feb 11 03:06 misc drwxr-xr-x 2 root root 4096 Feb 11 17:16 mnt drwxr-xr-x 2 root root 0 Jun 22 19:17 net drwxr-xr-x 2 root root 4096 Feb 11 17:16 opt dr-xr-xr-x 91 root root 0 Jun 22 20:15 proc drwxr-x--- 13 root root 4096 Jun 20 01:43 root drwxr-xr-x 2 root root 12288 Jun 20 22:37 sbin drwxr-xr-x 3 root root 0 Jun 22 20:15 selinux drwxr-xr-x 2 root root 4096 Feb 11 17:16 srv drwxr-xr-x 11 root root 0 Jun 22 20:15 sys -rw-r--r-- 1 root root 25 Jun 25 02:47 test_text_file drwxrwxrwt 10 root root 4096 Jun 25 02:48 tmp drwxr-xr-x 14 root root 4096 Jun 19 19:14 usr drwxr-xr-x 22 root root 4096 Jun 19 19:36 var Actual result: -------------- . = TRUE .. = TRUE .autofsck = FALSE bin = FALSE boot = FALSE dev = FALSE endeavour = FALSE etc = FALSE home = FALSE lib = FALSE lost+found = FALSE media = FALSE misc = FALSE mnt = FALSE net = FALSE opt = FALSE proc = FALSE root = FALSE sbin = FALSE selinux = FALSE srv = FALSE sys = FALSE test_text_file = FALSE tmp = FALSE usr = FALSE var = FALSE -- Edit bug report at http://bugs.php.net/?id=37910&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37910&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37910&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37910&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37910&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37910&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37910&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37910&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37910&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37910&r=support Expected behavior: http://bugs.php.net/fix.php?id=37910&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37910&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37910&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37910&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37910&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37910&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37910&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37910&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37910&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37910&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37910&r=mysqlcfg