Doc #63205 [NEW]: readdir() failure returns NULL instead of false
| From: | ai0867 at gmail dot com | Date: | Wed, 03 Oct 2012 09:30:30 +0000 |
| Subject: | Doc #63205 [NEW]: readdir() failure returns NULL instead of false | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-8927@lists.php.net to get a copy of this message | ||
From: ai0867 at gmail dot com
Operating system: Debian Squeeze
PHP version: 5.3.17
Package: Directory function related
Bug Type: Documentation Problem
Bug description:readdir() failure returns NULL instead of false
Description:
------------
---
From manual page:
http://www.php.net/function.readdir#refsect1-function.readdir-
returnvalues
---
readdir() should return the boolean value false on failure. When calling it
on a
failed opendir() result (false), it returns NULL instead.
http://www.php.net/manual/en/functions.internal.php
This indicates that this is intentional, but the readdir() documentation
says
nothing about this.
Test script:
---------------
$dir = opendir("/tmp/this-dir-does-not-exist");
$item = readdir($dir);
var_dump($item); // Should be false. Returns NULL on my machine
Expected result:
----------------
false
Actual result:
--------------
PHP Warning: opendir(/tmp/this-dir-does-not-exist): failed to open dir: No
such
file or directory in /home/ai/test.php on line 2
PHP Warning: readdir() expects parameter 1 to be resource, boolean given
in
test.php on line 3
NULL
--
Edit bug report at https://bugs.php.net/bug.php?id=63205&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63205&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63205&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63205&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63205&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63205&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63205&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63205&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63205&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63205&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63205&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63205&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63205&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63205&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63205&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63205&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63205&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63205&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63205&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63205&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63205&r=mysqlcfg