ID: 44246 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Assigned Bug Type: Directory function related Operating System: Windows XP PHP Version: 5.2CVS-2008-02-25 (CVS) -Assigned To: +Assigned To: felipe
Previous Comments: ------------------------------------------------------------------------ [2008-02-25 16:55:39] [EMAIL PROTECTED] Description: ------------ closedir() will accept a file resource opened by fopen() as the $directory argument. In the documentation for closedir() it says the following: "The stream must have previously been opened by opendir()". It seems that the resource type is not being checked correctly. A directory opened with opendir() can also be passed to fclose() without an error message being generated. Reproduce code: --------------- <?php var_dump($fp = fopen(__FILE__, 'r')); closedir($fp); var_dump($fp); $directory = dirname(__FILE__) . '/test'; mkdir($directory); var_dump($dh = opendir($directory)); var_dump(fclose($dh)); var_dump($dh); ?> Expected result: ---------------- resource(5) of type (stream) Warning: closedir(): supplied argument is not a valid Directory resource in ... resource(5) of type (stream) resource(6) of type (stream) Warning: fclose(): supplied argument is not a valid stream resource in ... bool(false) resource(6) of type (stream) Actual result: -------------- resource(5) of type (stream) resource(5) of type (Unknown) resource(6) of type (stream) bool(true) resource(6) of type (stream) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44246&edit=1