#34589 [Csd->Bgs]: Strange effects of file_exists() etc. caching
| From: | tony2001@php.net | Date: | Wed, 21 Sep 2005 21:00:20 +0000 |
| Subject: | #34589 [Csd->Bgs]: Strange effects of file_exists() etc. caching | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-85392@lists.php.net to get a copy of this message | ||
ID: 34589
Updated by: tony2001@php.net
Reported By: pjf at asn dot pl
-Status: Closed
+Status: Bogus
Bug Type: *Directory/Filesystem functions
Operating System: GNU
PHP Version: 5.0.5
Previous Comments:
------------------------------------------------------------------------
[2005-09-21 22:52:09] pjf at asn dot pl
To "outsmart the cache"... Rest in piece, Unix principles.
Hint for those who encounter the same problem as mine: use
realpath(). A hack, but works as file_exists() should.
------------------------------------------------------------------------
[2005-09-21 22:33:50] tony2001@php.net
No, I don't think so.
If you're trying to outsmart the cache jumping from/into different
directories and doing the stat() using *relative* path - this is not
PHP problem (and it can be easily solved with clearstatcache(), but
I've already told you that).
------------------------------------------------------------------------
[2005-09-21 22:21:44] pjf at asn dot pl
Don't you think that the key that is used to access the
cache should be the _full_, _absolute_ path instead of
just the string passed to file_exists()?
Current solution doesn't guarantee proper results - how do
you know whether the code you call doesn't change into
some other directory and stats() eg. "foo" won't interfere
with the other piece code checking for "foo" existence in
other directory? The only way to do such checks reliably
is to call clearstatcache() _each_ _time_ what makes the
cache useless. At least for me. I think it's a design
error.
------------------------------------------------------------------------
[2005-09-21 22:02:02] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Use clearstatcache() to clear the cache.
------------------------------------------------------------------------
[2005-09-21 21:55:45] pjf at asn dot pl
I made mistake in the code - here is the corrected
version:
touch("foobar");
echo file_exists("foobar") . "\n";
mkdir("foodir");
chdir("foodir");
echo file_exists("foobar") . "\n";
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/34589
--
Edit this bug report at http://bugs.php.net/?id=34589&edit=1