From: [EMAIL PROTECTED]
Operating system: Linux
PHP version: 4.2.3
PHP Bug Type: Filesystem function related
Bug description: file_exists() broken for relative paths
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 bug report at http://bugs.php.net/?id=19503&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=19503&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=19503&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=19503&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=19503&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=19503&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=19503&r=support
Expected behavior: http://bugs.php.net/fix.php?id=19503&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=19503&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=19503&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=19503&r=globals