Bug #64989 [Opn->Nab]: more accurate return value for readdir()
| From: | laruence@php.net | Date: | Fri, 07 Jun 2013 15:56:53 +0000 |
| Subject: | Bug #64989 [Opn->Nab]: more accurate return value for readdir() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-179413@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64989&edit=1
ID: 64989
Updated by: laruence@php.net
Reported by: vosa at binaryparadise dot com
Summary: more accurate return value for readdir()
-Status: Open
+Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: linux
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
return null on argument passing failed is expected and right behavior
if you enable E_WARNING report, you will find a warning is threw, like:
"PHP Warning: readdir() expects parameter 1 to be resource, string given"
Previous Comments:
------------------------------------------------------------------------
[2013-06-07 15:14:23] vosa at binaryparadise dot com
Sorry for bad example in original message. Correct one:
while(FALSE !== readdir('definitely_not_handler'));
------------------------------------------------------------------------
[2013-06-07 15:08:40] vosa at binaryparadise dot com
Description:
------------
---
From manual page: http://www.php.net/function.readdir#refsect1-function.readdir-examples
---
From documentation: "Returns the entry name on success or FALSE on failure." Function
returns NULL instead of FALSE in case of bad dir_handler. I think it should be mentioned in
documentation at least.
If dir_handler is not exactly resource, then i.e.: "while(FALSE ===
readdir('definitely_not_handler'));" can end very badly.
Test script:
---------------
var_dump(readdir('definitely_not_handler'));
Expected result:
----------------
FALSE
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64989&edit=1