php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42948 DirectoryIterator don't close handle
Submitted: 2007-10-12 12:59 UTC Modified: 2007-10-12 17:17 UTC
From: develar at gmail dot com Assigned:
Status: Closed Package: SPL related
PHP Version: 5.2.4 OS: Windows XP SP2
Private report: No CVE-ID: None
 [2007-10-12 12:59 UTC] develar at gmail dot com
Description:
------------
I can't delete directory after use DirectoryIterator. I read http://bugs.php.net/bug.php?id=35997

Reproduce code:
---------------
<?php

$root_dir_pathname = '/tmp/' . mt_rand();
mkdir($root_dir_pathname);
$DirectoryIterator = new DirectoryIterator($root_dir_pathname);
foreach ($DirectoryIterator as $SplFileInfo)
{

}

unset($DirectoryIterator);

rmdir($root_dir_pathname);

?>

Expected result:
----------------
no error

Actual result:
--------------
Warning: rmdir(/tmp/49058378) [function.rmdir]: Permission denied in C:\home\test\www\test.php on line 11

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-12 17:06 UTC] johannes@php.net
Why are you mixing Unix and Windows paths and please try unsetting $SplFileInfo, too.
 [2007-10-12 17:17 UTC] develar at gmail dot com
Big thanks. I unset($SplFileInfo); and it works. It is a little difficult to guess, but it is logically correct. This is bogus, excuse me :)
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Mar 30 21:01:23 2020 UTC