From: Numa dot Haase at uvm dot edu Operating system: Solaris PHP version: 5.2.5 PHP Bug Type: *Directory/Filesystem functions Bug description: glob returns FALSE instead of empty array when no files matched
Description: ------------ What I am reporting seems to me be the same as Bug #43461, but Jani and Ilia took the problem to be as in Bug #43407 where a directory in the path does not exist. Here we are in the current directory but simply cannot match any files. The documentation clearly states that in such a case the function will return an empty array. Nevertheless, we turned safe_mode off to see what would happen, and glob then returned an empty array as expected. However, we cannot run our web server with safe mode off. I think this was working up until the latest version 5.2.5. I can write everything with the opendir, readdir, etc. functions even with safe_mode on, so I don't quite follow Ilia's logic about bypassing safe_mode, but in any case, if the directory exists glob should return an empty array when no files are matched whether safe_mode is on or not. If not, the returned array from glob cannot be used (as it often is) in other functions expecting an array argument, and many things will break in a lot of existing code. If glob's behavior has indeed changed, then it needs to be noted in the documentation. Reproduce code: --------------- glob("*.jpg"); Expected result: ---------------- empty array Actual result: -------------- boolean FALSE -- Edit bug report at http://bugs.php.net/?id=43530&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43530&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43530&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43530&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43530&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43530&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43530&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43530&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43530&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43530&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43530&r=support Expected behavior: http://bugs.php.net/fix.php?id=43530&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43530&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43530&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43530&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43530&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43530&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43530&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43530&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43530&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43530&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43530&r=mysqlcfg