Bug #73488 [NEW]: DirectoryIterator::isDir() strange behavior
| From: | stan dot wanderer at gmail dot com | Date: | Thu, 10 Nov 2016 15:45:36 +0000 |
| Subject: | Bug #73488 [NEW]: DirectoryIterator::isDir() strange behavior | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-205285@lists.php.net to get a copy of this message | ||
From: stan dot wanderer at gmail dot com
Operating system: ubuntu 16.04.1 lts x64
PHP version: 7.0.13
Package: *Directory/Filesystem functions
Bug Type: Bug
Bug description:DirectoryIterator::isDir() strange behavior
Description:
------------
hello,
I've noticed that the DirectoryIterator object (as I know extended from
SplFileInfo) has strange behavior of method isDir() - random boolean
result on real directories.
I've tried to run my tests on different environments (the same
results):
Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-45-generic x86_64)
# php -v
PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016,
by Zend Technologies
Ubuntu 14.04.5 LTS (GNU/Linux 4.8.3-x86_64-linode76 x86_64)
# php -v
PHP 5.5.9-1ubuntu4.19 (cli) (built: Jul 28 2016 19:31:33)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend
Technologies
Maybe it is not a bug, but I cannot find any information about this
issue.
Please, contact with me if you need any additional information.
Hope this will make PHP better!
Test script:
---------------
<?php
foreach (scandir(__DIR__) as $f)
if (is_dir($f))
echo sprintf("%20s: %d\n", $f, (new
DirectoryIterator($f))->isDir());
Expected result:
----------------
bin: 1
boot: 1
dev: 1
etc: 1
home: 1
lib: 1
lib64: 1
lost+found: 1
media: 1
mnt: 1
opt: 1
proc: 1
root: 1
run: 1
sbin: 1
srv: 1
sys: 1
tmp: 1
usr: 1
var: 1
Actual result:
--------------
bin: 0
boot: 1
dev: 1
etc: 0
home: 1
lib: 1
lib64: 0
lost+found: 1
media: 1
mnt: 1
opt: 1
proc: 1
root: 0
run: 1
sbin: 1
srv: 1
sys: 1
tmp: 1
usr: 1
var: 1
--
Edit bug report at https://bugs.php.net/bug.php?id=73488&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73488&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73488&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73488&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73488&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73488&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73488&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73488&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73488&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73488&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73488&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73488&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73488&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73488&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73488&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73488&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73488&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73488&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73488&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73488&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73488&r=mysqlcfg