According to the php docs (https://www.php.net/manual/en/function.clearstatcache.php) the second argument is only used if the first argument is set to true.
Or maybe there is some secret feature i'm not aware of or am I reading the docs wrong ?
I've discovered this when working with flysystem v1, i have an issue with the listContents() method that keep seing a deleted file (tested on windows) resulting in lstat error.
using clearstatcache(true, $location) resolve the error, although it's not reasonable because clearing the cache for all files is not practical, i'd rather try to understand why deleting the file is not clearing the cache
the scenario is this
listContents => the file is there
delete the file
listContents => the file is still marked as there, but it causes lstat error because it was moved elsewhere
the error is like this
[Emergency] Uncaught RuntimeException: SplFileInfo::getType(): Lstat failed for .../somepath/e79c8f8d64\Document-v8.pdf
I don't know if the two issues are related (listContents serving out of date data and clearstatcache not being used according to the docs) but it's probably worth investigating. I haven't solved my issue so far.
This issue affects v1 and v2
In the Local adapter, there are calls to
clearstatcache
https://github.com/thephpleague/flysystem/blob/811bdc2d52a07eafbb6cb68a7b368b0668b362c8/src/Local/LocalFilesystemAdapter.php#L298
According to the php docs (https://www.php.net/manual/en/function.clearstatcache.php) the second argument is only used if the first argument is set to true. Or maybe there is some secret feature i'm not aware of or am I reading the docs wrong ?
I've discovered this when working with flysystem v1, i have an issue with the listContents() method that keep seing a deleted file (tested on windows) resulting in lstat error. using clearstatcache(true, $location) resolve the error, although it's not reasonable because clearing the cache for all files is not practical, i'd rather try to understand why deleting the file is not clearing the cache
the scenario is this
the error is like this [Emergency] Uncaught RuntimeException: SplFileInfo::getType(): Lstat failed for .../somepath/e79c8f8d64\Document-v8.pdf
I don't know if the two issues are related (listContents serving out of date data and clearstatcache not being used according to the docs) but it's probably worth investigating. I haven't solved my issue so far.