My workflow is pretty simple:
- I delete a file
- I call
clearstatcache()
- I save a new file
- I call
clearstatcache()
Still, at the end, is_file()
returns false
for a while before deciding to return true
when i refresh 10sec later for example.
It looks like a cache problem, doesn't it?
Here's a piece of my code:
// step 1
$path = 'file_to_delete.jpg';
unlink($path);
// is_file($path) returns false here -- normal behavior
// step 2
clearstatcache();
// step 3 -- some stuff going on on an uploaded image, that leads to:
imagejpeg($imagetosave, $path, 80);
// step 4
clearstatcache();
// is_file() returns false, i have to wait a couple of seconds before it starts returning true
Thank you for your help!
EDIT:
Given all the answers i had, the problem doesn't seem to come from clearstatcache()
.
But should i add, when i overwrite the file (thus its existing status doesn't change), is_file()
returns the good result. but when its existing status actually changes, the problem happens. It would be weird if the error didn't come from clearstatcache()
, right? (or something related to this cache indeed)