#43407 [Opn->Asn]: glob return not array if directory not exist
| From: | jani@php.net | Date: | Mon, 26 Nov 2007 11:06:57 +0000 |
| Subject: | #43407 [Opn->Asn]: glob return not array if directory not exist | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120072@lists.php.net to get a copy of this message | ||
ID: 43407
Updated by: jani@php.net
Reported By: ppalka7 at abacus dot pl
-Status: Open
+Status: Assigned
Bug Type: Filesystem function related
Operating System: CENTOS Ent 5 i686 2.6.18-8.1.8.e
PHP Version: 5.2.5
-Assigned To:
+Assigned To: iliaa
New Comment:
Ilia, shouldn't this return an empty array in case of open_basedir /
safe_mode being on as it does when they're NOT on? A bit inconsistency
here..
Previous Comments:
------------------------------------------------------------------------
[2007-11-26 10:55:13] ppalka7 at abacus dot pl
On affected system
phpinfo();
open_basedir /home/projekt5/:/usr/lib/php:/usr/local/lib/php:/tmp no
value
safe_mode Off On
------------------------------------------------------------------------
[2007-11-26 10:39:41] jani@php.net
There's some error happening and as documented, this function returns
FALSE then. Do you have open_basedir / safe_mode enabled?
------------------------------------------------------------------------
[2007-11-26 09:26:18] ppalka7 at abacus dot pl
Description:
------------
Glob return incorect types values if directory not exists
Reproduce code:
---------------
$arr=glob('directory/not/exists/*.jpg');
echo 'Is array-'.is_array($arr).'<br />';
echo 'Sizeof-'.sizeof($arr).'<br />';
echo '<pre>';
print_r($arr);
echo '</pre>';
foreach($arr as $key => $val)
{
echo $val;
}
Expected result:
----------------
php 5.2.4
Is array-1
Sizeof-0
Array
(
)
Actual result:
--------------
php 5.2.5
Is array-
Sizeof-1
Warning: Invalid argument supplied for foreach() in
/home/projekt5/public_html/phpbug/glob.php on line 14
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43407&edit=1