php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #27134 PHP CLI does not cache results of file_exists()
Submitted: 2004-02-03 10:12 UTC Modified: 2004-02-05 14:39 UTC
From: jaenecke@php.net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.4 OS: Slackware Linux
Private report: No CVE-ID: None
 [2004-02-03 10:12 UTC] jaenecke@php.net
Description:
------------
It seems that results from file_exists() or similar are not being cached with PHP-CLI. Since I think this is intended behavior this should be reflected in the manual.

Reproduce code:
---------------
while( TRUE ) {

   var_dump( file_exists( '/tmp/foo' ) );
   sleep( 1 );

} 

Expected result:
----------------
on creating/deleting /tmp/foo the result of file_exists() should not change since there is no call to clearstatcache()


Actual result:
--------------
actually the output _does_ change

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-03 10:22 UTC] nlopess@php.net
I've tested with PHP 5 and it caches in some situations.

If you start running the script without the file, it will output false till you create it.
If you then delete the file, it continues to echo true.
 [2004-02-04 12:56 UTC] wez@php.net
Results are only cached if the underlying stat() call succeeded; since the file doesn't exist to start off with,
PHP won't cached the information about it not existing.
 [2004-02-05 14:39 UTC] nlopess@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2004-09-08 17:57 UTC] djani22 at netcenter dot hu
I have a similar problem too:

...
clearstatcache();
if (file_exists($_SERVER['DOCUMENT_ROOT']."pic/penztarbamost_".$language.".gif")){
?> 
<img src="pic/penztarbamost_<?php echo($language); ?>.gif" border="0" alt="<?php echo($_SERVER['DOCUMENT_ROOT']."pic/penztarbamost_".$language.".gif"); ?>">
<?php }
...

The code is inserting the img tag, but the image does not exist!
(and newer was)

I tried to restart apache, but no change. :(

(the php script is a symlink, but the alt message on a missing image is correct.)

PHP 4.3.6RC2
RH 9.0
Apache 2.0.50
 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of nlopess
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=83c244195c6db71fdff28f650776c56ee94eda79
Log: fix #27134 php dont cache info about non-existent files
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Aug 17 02:01:29 2024 UTC