Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / http-kernel / HttpCache / Store.php
index c4d961e68f04318d29851bdec8338056a468454d..d20bfaa1b0c4c28ed18b47f14064ae80335af85a 100644 (file)
@@ -29,8 +29,6 @@ class Store implements StoreInterface
     private $locks;
 
     /**
-     * Constructor.
-     *
      * @param string $root The path to the cache directory
      *
      * @throws \RuntimeException
@@ -62,8 +60,6 @@ class Store implements StoreInterface
     /**
      * Tries to lock the cache for a given Request, without blocking.
      *
-     * @param Request $request A Request instance
-     *
      * @return bool|string true if the lock is acquired, the path to the current lock otherwise
      */
     public function lock(Request $request)
@@ -91,8 +87,6 @@ class Store implements StoreInterface
     /**
      * Releases the lock for the given Request.
      *
-     * @param Request $request A Request instance
-     *
      * @return bool False if the lock file does not exist or cannot be unlocked, true otherwise
      */
     public function unlock(Request $request)
@@ -133,8 +127,6 @@ class Store implements StoreInterface
     /**
      * Locates a cached Response for the Request provided.
      *
-     * @param Request $request A Request instance
-     *
      * @return Response|null A Response instance, or null if no cache entry was found
      */
     public function lookup(Request $request)
@@ -159,7 +151,7 @@ class Store implements StoreInterface
             return;
         }
 
-        list($req, $headers) = $match;
+        $headers = $match[1];
         if (file_exists($body = $this->getPath($headers['x-content-digest'][0]))) {
             return $this->restoreResponse($headers, $body);
         }
@@ -175,9 +167,6 @@ class Store implements StoreInterface
      * Existing entries are read and any that match the response are removed. This
      * method calls write with the new list of cache entries.
      *
-     * @param Request  $request  A Request instance
-     * @param Response $response A Response instance
-     *
      * @return string The key under which the response is stored
      *
      * @throws \RuntimeException
@@ -210,7 +199,7 @@ class Store implements StoreInterface
                 $entry[1]['vary'] = array('');
             }
 
-            if ($vary != $entry[1]['vary'][0] || !$this->requestsMatch($vary, $entry[0], $storedEnv)) {
+            if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) {
                 $entries[] = $entry;
             }
         }
@@ -230,8 +219,6 @@ class Store implements StoreInterface
     /**
      * Returns content digest for $response.
      *
-     * @param Response $response
-     *
      * @return string
      */
     protected function generateContentDigest(Response $response)
@@ -242,8 +229,6 @@ class Store implements StoreInterface
     /**
      * Invalidates all cache entries that match the request.
      *
-     * @param Request $request A Request instance
-     *
      * @throws \RuntimeException
      */
     public function invalidate(Request $request)
@@ -402,16 +387,22 @@ class Store implements StoreInterface
 
             $tmpFile = tempnam(dirname($path), basename($path));
             if (false === $fp = @fopen($tmpFile, 'wb')) {
+                @unlink($tmpFile);
+
                 return false;
             }
             @fwrite($fp, $data);
             @fclose($fp);
 
             if ($data != file_get_contents($tmpFile)) {
+                @unlink($tmpFile);
+
                 return false;
             }
 
             if (false === @rename($tmpFile, $path)) {
+                @unlink($tmpFile);
+
                 return false;
             }
         }
@@ -434,8 +425,6 @@ class Store implements StoreInterface
      * headers, use a Vary header to indicate them, and each representation will
      * be stored independently under the same cache key.
      *
-     * @param Request $request A Request instance
-     *
      * @return string A key for the given Request
      */
     protected function generateCacheKey(Request $request)
@@ -446,8 +435,6 @@ class Store implements StoreInterface
     /**
      * Returns a cache key for the given Request.
      *
-     * @param Request $request A Request instance
-     *
      * @return string A key for the given Request
      */
     private function getCacheKey(Request $request)
@@ -462,8 +449,6 @@ class Store implements StoreInterface
     /**
      * Persists the Request HTTP headers.
      *
-     * @param Request $request A Request instance
-     *
      * @return array An array of HTTP headers
      */
     private function persistRequest(Request $request)
@@ -474,8 +459,6 @@ class Store implements StoreInterface
     /**
      * Persists the Response HTTP headers.
      *
-     * @param Response $response A Response instance
-     *
      * @return array An array of HTTP headers
      */
     private function persistResponse(Response $response)