#47358 [Opn->Bgs]: glob returns error, should be empty array()
| From: | iliaa@php.net | Date: | Wed, 11 Feb 2009 14:20:52 +0000 |
| Subject: | #47358 [Opn->Bgs]: glob returns error, should be empty array() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-133718@lists.php.net to get a copy of this message | ||
ID: 47358
Updated by: iliaa@php.net
Reported By: php at guggemand dot dk
-Status: Open
+Status: Bogus
Bug Type: Safe Mode/open_basedir
Operating System: FreeBSD 7.1
PHP Version: 5.2.9RC1
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
The function is documented to return FALSE on error. There is no
problem
here...
Previous Comments:
------------------------------------------------------------------------
[2009-02-11 08:12:10] php at guggemand dot dk
Description:
------------
glob() cant be used directly in foreach when open_basedir is set.
i found #41655 which is about the change causing this, and a few other
closed tickets with "not a bug" as answer.
But that change destroys foreach(glob("nonexistent*") as ... when using
open_basedir, and the following comment in dir.c states that should be
usable.
/* Some glob implementation simply return no data if no matches
were found, others return the GLOB_NOMATCH error code.
We don't want to treat GLOB_NOMATCH as an error condition
so that PHP glob() behaves the same on both types of
implementations and so that 'foreach (glob() as ...'
can be used for simple glob() calls without further error
checking.
*/
As far as i can tell the right thing to do would be to return an empty
array both when using glob("/etc/hosts") and glob("/etc/nonexistent")
when open_basedir is used. Or what am i missing?
Ive been using the following patch, and as far as i can tell its not
possible to check if a file exists when open_basedir is used, and
foreach(glob("nonext*")) works correctly.
http://gugge.dlx.dk/ting/php5-patch-dir.c
Reproduce code:
---------------
set open_basedir /documentroot
open /documentroot/test.php with the following content
<? var_dump(glob("nonexistent*")); ?>
Expected result:
----------------
array(0) {
}
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47358&edit=1