#47358 [NEW]: glob returns error, should be empty array()

From: Date: Wed, 11 Feb 2009 08:12:11 +0000
Subject: #47358 [NEW]: glob returns error, should be empty array()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133700@lists.php.net to get a copy of this message
From: php at guggemand dot dk Operating system: FreeBSD 7.1 PHP version: 5.2.9RC1 PHP Bug Type: Safe Mode/open_basedir Bug description: glob returns error, should be empty array() 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 bug report at http://bugs.php.net/?id=47358&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47358&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47358&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47358&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47358&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47358&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47358&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47358&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47358&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47358&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47358&r=support Expected behavior: http://bugs.php.net/fix.php?id=47358&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47358&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47358&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47358&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47358&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47358&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47358&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47358&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47358&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47358&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47358&r=mysqlcfg

« previous php.bugs (#133700) next »