php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48062 file_exists() and clearstatcache() not working on network volume
Submitted: 2009-04-23 15:39 UTC Modified: 2009-05-14 01:00 UTC
Votes:6
Avg. Score:4.2 ± 0.9
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:2 (33.3%)
From: dlafond at lenouvelliste dot qc dot ca Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.2.9 OS: MacOSX Server 10.5.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dlafond at lenouvelliste dot qc dot ca
New email:
PHP Version: OS:

 

 [2009-04-23 15:39 UTC] dlafond at lenouvelliste dot qc dot ca
Description:
------------
When files are saved on AFP or SMB mounted sharing, file_exists() and 
clearstatcache() function are not working as expected. No problem when 
files are saved on local disk. On AFP or SMB volume, file_exists 
continue to return true when the file is deleted outside of PHP. 
clearstatcache() function seems to have no effect.

But, if the file is deleted with the unlink() function in php, 
file_exists return false.







Reproduce code:
---------------
<?
header("Content-type: text/html");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache,must-revalidate");
header("Cache-Control: post-check=0, pre-check=0",false);
header("Pragma: no-cache");


clearstatcache();

$ttt="/Volumes/testdaniel/ttt.txt";
#exec("touch ".$ttt);
#@unlink($ttt);

if(file_exists($ttt)){
   echo "exists";
}else{
   echo "not exists";
}
clearstatcache();

?>

Expected result:
----------------
"exists" when file really exists
"not exists" when file doesn't exists

Actual result:
--------------
"exists" even after the file was deleted

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-27 15:30 UTC] jani@php.net
Same issue as in bug #46245
 [2009-04-28 13:41 UTC] dlafond at lenouvelliste dot qc dot ca
A workaround to get rid of this persistent stat cache when using 
file_exists is to combine the file_exists function with the function 
realpath().

$ttt="/Volumes/testdaniel/ttt.txt";
if(file_exists(realpath($ttt))){
   echo "exists";
}else{
   echo "not exists";
}
 [2009-05-06 18:53 UTC] jani@php.net
Can you try this:

# CFLAGS=`getconf LFS_CFLAGS` ./config.nice
# make clean && make

This is from bug #45040 which I think this is kind of duplicate report 
now. :)
 [2009-05-14 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2015-08-10 03:03 UTC] p dot dolgov at infocomdv dot ru
Experiencing the same problem.

clearstatcache() does not clear cache for file_exists() and is_file().

Sample code:
$path = /images/logo.png;
clearstatcache();
if( file_exists($path) ) // also tried file_exists(realpath($path))
    $exists = true;	
else 
    $exists = false;		
clearstatcache();
echo "file is $path <br>";
echo "file exists is $exists";
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 08:01:28 2024 UTC