#19299 [NEW]: is_readable and other file functions report 'Can't stat'
| From: | nic at coombs dot anu dot edu dot au | Date: | Mon, 09 Sep 2002 06:15:22 +0000 |
| Subject: | #19299 [NEW]: is_readable and other file functions report 'Can't stat' | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-18719@lists.php.net to get a copy of this message | ||
From: nic@coombs.anu.edu.au
Operating system: Solaris 7
PHP version: 4.2.2
PHP Bug Type: *Directory/Filesystem functions
Bug description: is_readable and other file functions report 'Can't stat'
is_readable(), file_exists() and possibly other similar functions return
Warning stat failed errors if the file for which the function is called is
in a directory for which the www user (Apache) does not have permissions
to read.
The functions still return the appropriate values, but the error output is
annoying. While I undestand why the error is occuring, a function with a
name such as is_readable should suppress these warnings and simply return
false if it cannot read the file.
Thanks, Nic.
Code and error stuff follow.
<?PHP
echo $file;
echo ": ";
if (file_exists($file)) {
echo " exists";
}
else {
echo " dont exist";
}
if(is_readable($file)) {
echo "readable";
}
else {echo "not readable";}
?>
In the case below the directory 'poo' is not world readable, but does
exist.
poo/poo.txt:
Warning: stat failed for poo/poo.txt (errno=13 - Permission denied) in
/opt/apache_1.3.26/htdocs/is_read_test.php on line 6
dont exist
Warning: stat failed for poo/poo.txt (errno=13 - Permission denied) in
/opt/apache_1.3.26/htdocs/is_read_test.php on line 12
not readable
--
Edit bug report at http://bugs.php.net/?id=19299&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=19299&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=19299&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=19299&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=19299&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=19299&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=19299&r=support
Expected behavior: http://bugs.php.net/fix.php?id=19299&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=19299&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=19299&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=19299&r=globals