Bug #77077 [NEW]: rmdir() should return FALSE if directory locked by dir()
| From: | edgaras dot janusauskas at gmail dot com | Date: | Sun, 28 Oct 2018 20:45:18 +0000 |
| Subject: | Bug #77077 [NEW]: rmdir() should return FALSE if directory locked by dir() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217734@lists.php.net to get a copy of this message | ||
From: edgaras dot janusauskas at gmail dot com
Operating system: Windows 10
PHP version: 7.2.11
Package: *Directory/Filesystem functions
Bug Type: Bug
Bug description:rmdir() should return FALSE if directory locked by dir()
Description:
------------
On Windows, if directory is opened by dir() or opendir(), but not
closed, then call to rmdir() on that directory returns TRUE, but then
there is few inconsistencies exist:
- Second call to rmdir() on same directory fails (Permission denied)
- You cannot delete parent directory (Directory not empty)
- glob() doesn't see directory, but scandir() still sees it as
existing.
Test script:
---------------
mkdir('testdir');
mkdir('testdir/sub');
$d = dir('testdir/sub');
while (false !== ($entry = $d->read())) {
//echo $entry . "\n";
}
//$d->close();
printf("rmdir=%d\n", rmdir('testdir/sub'));
printf("glob=[%s]\n", implode(', ', glob('testdir/*')));
printf("scandir=[%s]\n", implode(', ', scandir('testdir')));
Expected result:
----------------
rmdir() should really succeed deleting folder and any further operations
should work as with not existing one.
rmdir=1
glob=[]
scandir=[., ..]
Deleting parent directory succeeds
or
rmdir() should fail with "Permission denied" on first try and any
further operations should work as with still existing one.
rmdir=0
glob=[testdir/sub]
scandir=[., .., sub]
Deleting parent directory fails
Actual result:
--------------
rmdir=1
glob=[] on PHP 7.0-7.2
glob=[testdir/sub] on PHP 5.6
scandir=[., .., sub]
--
Edit bug report at https://bugs.php.net/bug.php?id=77077&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77077&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77077&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77077&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77077&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77077&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77077&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77077&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77077&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77077&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77077&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77077&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77077&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77077&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77077&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77077&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77077&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77077&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77077&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77077&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77077&r=mysqlcfg