#19503 [Opn->Csd]: file_exists() broken for relative paths

From: Date: Thu, 19 Sep 2002 19:10:13 +0000
Subject: #19503 [Opn->Csd]: file_exists() broken for relative paths
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-19792@lists.php.net to get a copy of this message
ID: 19503 Updated by: iliaa@php.net Reported By: nick@nplawes.com -Status: Open +Status: Closed Bug Type: Filesystem function related Operating System: Linux PHP Version: 4.2.3 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#19792) next »