Edit report at https://bugs.php.net/bug.php?id=55468&edit=1
ID: 55468 User updated by: php at tracking-celebs dot info Reported by: php at tracking-celebs dot info Summary: UnexpectedValueException caused by an unreleased handle or something -Status: Feedback +Status: Open Type: Bug Package: SPL related Operating System: win32 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Permissions aren't a problem here. Besides, the (first, $foo) folder actually gets removed (as indicated by the output of file_exists), that's not the problem. And the problem comes before trying to remove the other one ($folder), it is that when calling the iterator (on that parent), because it'll somehow still "hold"/find a reference to the now non-existing/freshly removed folder, thus causing the exception... Previous Comments: ------------------------------------------------------------------------ [2011-08-22 13:58:59] ka...@php.net At first glance it doesn't looks like a problem in PHP itself but more that you haven't granted yourself the permission to delete the folder on Windows. Have you tried to chmod or similar it? ------------------------------------------------------------------------ [2011-08-20 19:56:20] php at tracking-celebs dot info 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 this bug report at https://bugs.php.net/bug.php?id=55468&edit=1