From:
Operating system: win32
PHP version: Irrelevant
Package: SPL related
Bug Type: Bug
Bug description:UnexpectedValueException caused by an unreleased handle or
something
Description:
------------
After using a DirectoryIterator on a folder, then removing said folder,
using another iterator to iterate on the folder's parent will see/try to
look into the removed folder.
This only happens on Windows, so maybe due to a cache somewhere or
something. Tried adding a clearstatcache() just in case, but that doesn't
change anything.
FYI if you replace the first DirectoryIterator by a:
opendir($foo);
without calling closedir() you get the same error, hence why I suggested it
might be a handle not (properly) released or something.
Test script:
---------------
<?php
$folder = 'V:\\tmp\\foobar';
if (file_exists($folder)) die("$folder already exists");
if (!mkdir($folder)) die("unable to create $folder");
$foo = $folder . '\\foo';
if (!mkdir($foo)) die("unable to create $foo");
$iterator = new DirectoryIterator($foo);
foreach ($iterator as $fi) { }
unset($iterator);
if (!rmdir($foo)) die("unable to delete $foo");
var_dump(file_exists($foo));
$iterator = new RecursiveIteratorIterator(new
RecursiveDirectoryIterator($folder),
RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $fi) { }
unset($iterator);
if (!rmdir($folder)) die("unable to delete $folder");
Expected result:
----------------
bool(false)
Actual result:
--------------
bool(false)
Fatal error: Uncaught exception 'UnexpectedValueException' with message
'RecursiveDirectoryIterator::__construct(V:\tmp\foobar\foo,V:\tmp\foobar\foo):
Access is denied. (code: 5)' in V:\test\test.php on line 35
--
Edit bug report at https://bugs.php.net/bug.php?id=55468&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55468&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55468&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55468&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55468&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55468&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55468&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55468&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55468&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55468&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55468&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55468&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55468&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55468&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55468&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55468&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55468&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55468&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55468&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55468&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55468&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55468&r=mysqlcfg