#43530 [Opn]: glob returns FALSE instead of empty array when no files matched

From: Date: Fri, 07 Dec 2007 23:56:58 +0000
Subject: #43530 [Opn]: glob returns FALSE instead of empty array when no files matched
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-327@lists.php.net to get a copy of this message
ID: 43530 Updated by: jani@php.net Reported By: Numa dot Haase at uvm dot edu Status: Open -Bug Type: *Directory/Filesystem functions +Bug Type: Documentation problem Operating System: Solaris PHP Version: 5.2.5 New Comment: Reclassified. Previous Comments: ------------------------------------------------------------------------ [2007-12-07 20:31:56] Numa dot Haase at uvm dot edu 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 this bug report at http://bugs.php.net/?id=43530&edit=1

« previous php.doc.bugs (#327) next »