Doc #75136 [Com]: readdir is returning null.
| From: | mail at pmmaga dot net | Date: | Wed, 30 Aug 2017 13:01:39 +0000 |
| Subject: | Doc #75136 [Com]: readdir is returning null. | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14933@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75136&edit=1
ID: 75136
Comment by: mail at pmmaga dot net
Reported by: dmitriy dot vinograd at gmail dot com
Summary: readdir is returning null.
Status: Feedback
Type: Documentation Problem
Package: Directory function related
Operating System: Ubuntu 16.04.3 LTS
PHP Version: 7.0.22
Block user comment: N
Private report: N
New Comment:
The documentation actually alerts you that this is a possible return value. Quoting:
Warning
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to
FALSE. Please read the section on Booleans for more information. Use the === operator for testing
the return value of this function.
Previous Comments:
------------------------------------------------------------------------
[2017-08-30 12:57:50] salathe@php.net
What makes you think false is a valid argument for the function?
------------------------------------------------------------------------
[2017-08-30 12:51:10] dmitriy dot vinograd at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.readdir
---
readdir(false) is returning a null, despite the fact documentation says it must be a string or false
Which may put the example from the documentation in an infinitive loop, and in case if a server is
saving warning messages into a log it will fill the server disk that in turn will put the server
offline.
Test script:
---------------
var_dump(readdir(false));
//Will return
// Warning: readdir() expects parameter 1 to be resource, boolean given in /..../test.php on line 11
// /..../test.php:11:null
while (false !== ($logFile = readdir(false)))
{
var_dump($logFile);
}
// Will put your process an infinitive loop
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75136&edit=1