thephpleague / flysystem

Abstraction for local and remote filesystems
https://flysystem.thephpleague.com
MIT License
13.37k stars 831 forks source link

clearstatcache should use true as first argument according to php docs #1352

Closed lekoala closed 3 years ago

lekoala commented 3 years ago

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.

frankdejonge commented 3 years ago

fixed for next release