summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-02-12 01:14:38 (GMT)
committerNathaniel Catchpole2016-02-12 01:14:38 (GMT)
commitb97d20d9b6f1e8075fb61cae59fdbc796ae58f6e (patch)
tree17b3fe18be717623f13868cccc8732f1683c660d
parentd87ade36a470b9d7f8ff5a062a4e3babf69ef938 (diff)
Issue #2575847 by znerol: Remove request policy attribute from dynamic page cache subscriber
-rw-r--r--core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php b/core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php
index 7602b4d..63689a1 100644
--- a/core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php
+++ b/core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php
@@ -41,14 +41,6 @@ use Symfony\Component\HttpKernel\KernelEvents;
class DynamicPageCacheSubscriber implements EventSubscriberInterface {
/**
- * Attribute name of the Dynamic Page Cache request policy result.
- *
- * @see onRouteMatch()
- * @see onRespond()
- */
- const ATTRIBUTE_REQUEST_POLICY_RESULT = '_dynamic_page_cache_request_policy_result';
-
- /**
* Name of Dynamic Page Cache's response header.
*/
const HEADER = 'X-Drupal-Dynamic-Cache';
@@ -104,6 +96,13 @@ class DynamicPageCacheSubscriber implements EventSubscriberInterface {
];
/**
+ * Internal cache of request policy results.
+ *
+ * @var \SplObjectStorage
+ */
+ protected $requestPolicyResults;
+
+ /**
* Constructs a new DynamicPageCacheSubscriber object.
*
* @param \Drupal\Core\PageCache\RequestPolicyInterface $request_policy
@@ -120,6 +119,7 @@ class DynamicPageCacheSubscriber implements EventSubscriberInterface {
$this->responsePolicy = $response_policy;
$this->renderCache = $render_cache;
$this->rendererConfig = $renderer_config;
+ $this->requestPolicyResults = new \SplObjectStorage();
}
/**
@@ -134,7 +134,7 @@ class DynamicPageCacheSubscriber implements EventSubscriberInterface {
// does not have to redo the request policy check.
$request = $event->getRequest();
$request_policy_result = $this->requestPolicy->check($request);
- $request->attributes->set(self::ATTRIBUTE_REQUEST_POLICY_RESULT, $request_policy_result);
+ $this->requestPolicyResults[$request] = $request_policy_result;
if ($request_policy_result === RequestPolicyInterface::DENY) {
return;
}
@@ -189,14 +189,14 @@ class DynamicPageCacheSubscriber implements EventSubscriberInterface {
// @see \Drupal\Core\Routing\AccessAwareRouter::checkAccess()
// @see \Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber::on403()
$request = $event->getRequest();
- if (!$request->attributes->has(self::ATTRIBUTE_REQUEST_POLICY_RESULT)) {
+ if (!isset($this->requestPolicyResults[$request])) {
return;
}
// Don't cache the response if the Dynamic Page Cache request & response
// policies are not met.
// @see onRouteMatch()
- if ($request->attributes->get(self::ATTRIBUTE_REQUEST_POLICY_RESULT) === RequestPolicyInterface::DENY || $this->responsePolicy->check($response, $request) === ResponsePolicyInterface::DENY) {
+ if ($this->requestPolicyResults[$request] === RequestPolicyInterface::DENY || $this->responsePolicy->check($response, $request) === ResponsePolicyInterface::DENY) {
return;
}