Mercurial > hg > isophonics-drupal-site
diff core/modules/page_cache/src/StackMiddleware/PageCache.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
line wrap: on
line diff
--- a/core/modules/page_cache/src/StackMiddleware/PageCache.php Thu Feb 28 13:21:36 2019 +0000 +++ b/core/modules/page_cache/src/StackMiddleware/PageCache.php Thu May 09 15:33:08 2019 +0100 @@ -48,6 +48,13 @@ protected $responsePolicy; /** + * The cache ID for the (master) request. + * + * @var string + */ + protected $cid; + + /** * Constructs a PageCache object. * * @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel @@ -339,11 +346,20 @@ * The cache ID for this request. */ protected function getCacheId(Request $request) { - $cid_parts = [ - $request->getSchemeAndHttpHost() . $request->getRequestUri(), - $request->getRequestFormat(), - ]; - return implode(':', $cid_parts); + // Once a cache ID is determined for the request, reuse it for the duration + // of the request. This ensures that when the cache is written, it is only + // keyed on request data that was available when it was read. For example, + // the request format might be NULL during cache lookup and then set during + // routing, in which case we want to key on NULL during writing, since that + // will be the value during lookups for subsequent requests. + if (!isset($this->cid)) { + $cid_parts = [ + $request->getSchemeAndHttpHost() . $request->getRequestUri(), + $request->getRequestFormat(NULL), + ]; + $this->cid = implode(':', $cid_parts); + } + return $this->cid; } }