File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -290,16 +290,16 @@ protected function encodeFilename($keyword): string
290290 */
291291 protected function readFile ($ file ): string
292292 {
293+ if (!\is_readable ($ file )) {
294+ throw new PhpfastcacheIOException ("Cannot read file located at: {$ file }" );
295+ }
293296 if (\function_exists ('file_get_contents ' )) {
294297 return (string )\file_get_contents ($ file );
295298 }
296299
297300 $ string = '' ;
298301
299302 $ file_handle = @\fopen ($ file , 'rb ' );
300- if (!$ file_handle ) {
301- throw new PhpfastcacheIOException ("Cannot read file located at: {$ file }" );
302- }
303303 while (!\feof ($ file_handle )) {
304304 $ line = \fgets ($ file_handle );
305305 $ string .= $ line ;
Original file line number Diff line number Diff line change 2020use FilesystemIterator ;
2121use Phpfastcache \Cluster \AggregatablePoolInterface ;
2222use Phpfastcache \Core \Pool \{DriverBaseTrait , ExtendedCacheItemPoolInterface , IO \IOHelperTrait };
23- use Phpfastcache \Exceptions \{PhpfastcacheInvalidArgumentException };
23+ use Phpfastcache \Exceptions \{PhpfastcacheInvalidArgumentException , PhpfastcacheIOException };
2424use Phpfastcache \Util \Directory ;
2525use Psr \Cache \CacheItemInterface ;
2626
@@ -74,16 +74,14 @@ protected function driverConnect(): bool
7474 */
7575 protected function driverRead (CacheItemInterface $ item )
7676 {
77- /**
78- * Check for Cross-Driver type confusion
79- */
8077 $ file_path = $ this ->getFilePath ($ item ->getKey (), true );
81- if (!\file_exists ($ file_path )) {
78+
79+ try {
80+ $ content = $ this ->readFile ($ file_path );
81+ }catch (PhpfastcacheIOException $ e ){
8282 return null ;
8383 }
8484
85- $ content = $ this ->readFile ($ file_path );
86-
8785 return $ this ->decode ($ content );
8886 }
8987
You can’t perform that action at this time.
0 commit comments