Skip to content

Commit d81196c

Browse files
committed
bug #779 do not try to write a cache entry if there is no cache key (themasch)
This PR was merged into the 1.13-dev branch. Discussion ---------- do not try to write a cache entry if there is no cache key Writing to the cache with an empty key will fail with "failed to open stream: Is a directory", so do not try to do that. We noticed this when cloudflare - or the backend service - responded with a "last-modified" header for our CI servers (AWS) but not for our local system. This triggered the condition to become true and it tries to write a cache file without a filename. I hope this is the correct place to fix it, but from what I see, this code should not try to write a cache with am empty key, correct? Here is how a `composer install` failed for us (because of this?): ``` [ErrorException] file_put_contents(/tmp/composer/cache/repo/https---flex.symfony.com/): failed to open stream: Is a directory ``` Commits ------- e4bb94d do not write a cache entry if there is no cache key
2 parents 2597d0d + e4bb94d commit d81196c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Downloader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ private function parseJson(string $json, string $url, string $cacheKey, array $l
293293
}
294294

295295
$response = new Response($data, $lastHeaders);
296-
if ($response->getHeader('last-modified')) {
296+
if ($response->getHeader('last-modified') && $cacheKey) {
297297
$this->cache->write($cacheKey, json_encode($response));
298298
}
299299

0 commit comments

Comments
 (0)