#19503 [Com]: file_exists() broken for relative paths
| From: | fil at rezo dot net | Date: | Sat, 21 Sep 2002 21:20:43 +0000 |
| Subject: | #19503 [Com]: file_exists() broken for relative paths | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-20018@lists.php.net to get a copy of this message | ||
ID: 19503
Comment by: fil@rezo.net
Reported By: nick@nplawes.com
Status: Closed
Bug Type: Filesystem function related
Operating System: Linux
PHP Version: 4.2.3
New Comment:
I have just installed php 4.2.3 on Mac OS X/Jaguar, and
file_exists() always returns false ; for the test programme
sent by Nick, I get
Starting from '/Users/fil/Sites' (allegedly)
Looking for 'System.map'
0 0 : '' (/Users/fil/Sites/System.map)
0 0 : '../' (/Users/fil/System.map)
0 0 : '../../' (/Users/System.map)
0 0 : '../../../' (/System.map)
0 0 : '../../../../' (/System.map)
0 0 : '../../../../../' (/System.map)
0 0 : '../../../../../../' (/System.map)
0 0 : '../../../../../../../' (/System.map)
0 0 : '../../../../../../../../' (/System.map)
0 0 : '../../../../../../../../../' (/System.map)
0 0 : '../../../../../../../../../../' (/System.map)
0 0 : '../../../../../../../../../../../' (/System.map)
0 0 : '../../../../../../../../../../../../' (/System.map)
0 0 : '../../../../../../../../../../../../../'
(/System.map)
0 0 : '../../../../../../../../../../../../../../'
(/System.map)
0 0 : '../../../../../../../../../../../../../../../'
(/System.map)
0 0 : '../../../../../../../../../../../../../../../../'
(/System.map)
0 0 : '../../../../../../../../../../../../../../../../../'
(/System.map)
0 0 :
'../../../../../../../../../../../../../../../../../../'
(/System.map)
0 0 :
'../../../../../../../../../../../../../../../../../../../'
(/System.map)
Looking for 'is_file.php'
0 0 : '' (/Users/fil/Sites/is_file.php)
0 0 : '../' (/Users/fil/is_file.php)
0 0 : '../../' (/Users/is_file.php)
0 0 : '../../../' (/is_file.php)
0 0 : '../../../../' (/is_file.php)
0 0 : '../../../../../' (/is_file.php)
0 0 : '../../../../../../' (/is_file.php)
0 0 : '../../../../../../../' (/is_file.php)
0 0 : '../../../../../../../../' (/is_file.php)
0 0 : '../../../../../../../../../' (/is_file.php)
0 0 : '../../../../../../../../../../' (/is_file.php)
0 0 : '../../../../../../../../../../../' (/is_file.php)
0 0 : '../../../../../../../../../../../../' (/is_file.php)
0 0 : '../../../../../../../../../../../../../'
(/is_file.php)
0 0 : '../../../../../../../../../../../../../../'
(/is_file.php)
0 0 : '../../../../../../../../../../../../../../../'
(/is_file.php)
0 0 : '../../../../../../../../../../../../../../../../'
(/is_file.php)
0 0 : '../../../../../../../../../../../../../../../../../'
(/is_file.php)
0 0 :
'../../../../../../../../../../../../../../../../../../'
(/is_file.php)
0 0 :
'../../../../../../../../../../../../../../../../../../../'
(/is_file.php)
Looking for 'index.php'
0 0 : '' (/Users/fil/Sites/index.php)
0 0 : '../' (/Users/fil/index.php)
0 0 : '../../' (/Users/index.php)
0 0 : '../../../' (/index.php)
0 0 : '../../../../' (/index.php)
0 0 : '../../../../../' (/index.php)
0 0 : '../../../../../../' (/index.php)
0 0 : '../../../../../../../' (/index.php)
0 0 : '../../../../../../../../' (/index.php)
0 0 : '../../../../../../../../../' (/index.php)
0 0 : '../../../../../../../../../../' (/index.php)
0 0 : '../../../../../../../../../../../' (/index.php)
0 0 : '../../../../../../../../../../../../' (/index.php)
0 0 : '../../../../../../../../../../../../../'
(/index.php)
0 0 : '../../../../../../../../../../../../../../'
(/index.php)
0 0 : '../../../../../../../../../../../../../../../'
(/index.php)
0 0 : '../../../../../../../../../../../../../../../../'
(/index.php)
0 0 : '../../../../../../../../../../../../../../../../../'
(/index.php)
0 0 :
'../../../../../../../../../../../../../../../../../../'
(/index.php)
0 0 :
'../../../../../../../../../../../../../../../../../../../'
(/index.php)
Previous Comments:
------------------------------------------------------------------------
[2002-09-19 14:10:13] iliaa@php.net
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2002-09-19 13:41:50] nick@nplawes.com
Hi
I can see many "Closed" versions of this bug report. It definitely is
causing me problems, hence this report. I think that Apache 2.0.39 /
php 4.2.1 was working, as my code broke after installing Apache 2.0.40
/ php 4.2.3.
I always build apache and php with the same options. The server is
running as 'nobody'.
is_file() behaves better, although it's not the function I want to
use.
A test case... (is_file.php) I would expect is_file and file_exists to
give the same results in this test... They don't!
<?php
function lookfor($filename)
{
$wd = getcwd();
echo "<b>Looking for '$filename'</b><br>\n";
$path = "";
for ($i = 0; $i < 20; $i++)
{
$if = is_file($path . $filename) ? 1 : 0;
clearstatcache();
$fe = file_exists($path . $filename) ? 1 : 0;
echo "$if $fe : '$path' ($wd/$filename)<br>\n";
if ($if) break;
$path .= "../";
$wd = dirname($wd);
if ($wd == "/") $wd = "";
}
echo "<br>\n";
}
echo "Starting from '".getcwd()."' (allegedly)<br>\n";
lookfor('System.map');
lookfor('is_file.php');
lookfor('index.php');
?>
Gives:
Starting from '/usr/local/apache2/htdocs/test' (allegedly)
Looking for 'System.map'
0 1 : '' (/usr/local/apache2/htdocs/test/System.map)
0 1 : '../' (/usr/local/apache2/htdocs/System.map)
0 1 : '../../' (/usr/local/apache2/System.map)
0 1 : '../../../' (/usr/local/System.map)
0 1 : '../../../../' (/usr/System.map)
1 1 : '../../../../../' (/System.map)
Looking for 'is_file.php'
1 0 : '' (/usr/local/apache2/htdocs/test/is_file.php)
Looking for 'index.php'
0 0 : '' (/usr/local/apache2/htdocs/test/index.php)
1 0 : '../' (/usr/local/apache2/htdocs/index.php)
Thanks
/nick
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19503&edit=1