File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,6 @@ public static function create(string $cacheFile): self
4040
4141 public static function load (string $ cacheFile ): self
4242 {
43- if (!is_readable ($ cacheFile )) {
44- throw new DbaException (sprintf ('Cache file "%s" is not readable ' , $ cacheFile ));
45- }
46-
4743 $ reflectionCache = new self ($ cacheFile );
4844 $ cachedRecords = $ reflectionCache ->readCache ();
4945 if (null !== $ cachedRecords ) {
@@ -58,6 +54,11 @@ public static function load(string $cacheFile): self
5854 */
5955 private function readCache (): ?array
6056 {
57+ if (!is_file ($ this ->cacheFile )) {
58+ if (false === file_put_contents ($ this ->cacheFile , '' )) {
59+ throw new DbaException (sprintf ('Cache file "%s" is not readable and creating a new one did not succeed. ' , $ this ->cacheFile ));
60+ }
61+ }
6162 clearstatcache (true , $ this ->cacheFile );
6263 $ cache = require $ this ->cacheFile ;
6364
You can’t perform that action at this time.
0 commit comments