diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index f5acae3..281ab9c 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1450,8 +1450,8 @@ function _drupal_bootstrap_configuration() { Unicode::check(); // Set the Drupal custom error handler. (requires \Drupal::config()) - # set_error_handler('_drupal_error_handler'); - # set_exception_handler('_drupal_exception_handler'); + set_error_handler('_drupal_error_handler'); + set_exception_handler('_drupal_exception_handler'); // Redirect the user to the installation script if Drupal has not been // installed yet (i.e., if no $databases array has been defined in the diff --git a/core/lib/Drupal/Core/PageCache/CacheControlResponseSubscriber.php b/core/lib/Drupal/Core/PageCache/CacheControlResponseSubscriber.php index 3934aee..a43496a 100644 --- a/core/lib/Drupal/Core/PageCache/CacheControlResponseSubscriber.php +++ b/core/lib/Drupal/Core/PageCache/CacheControlResponseSubscriber.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\PageCache\CacheControlResponseSubscriber. + * Contains Drupal\Core\PageCache\CacheControlResponseSubscriber. */ namespace Drupal\Core\PageCache; diff --git a/core/lib/Drupal/Core/PageCache/CacheControlResponseSubscriberBase.php b/core/lib/Drupal/Core/PageCache/CacheControlResponseSubscriberBase.php index d96510e..20f5e8e 100644 --- a/core/lib/Drupal/Core/PageCache/CacheControlResponseSubscriberBase.php +++ b/core/lib/Drupal/Core/PageCache/CacheControlResponseSubscriberBase.php @@ -2,15 +2,16 @@ /** * @file - * Definition of Drupal\Core\PageCache\CacheControlResponseSubscriberBase. + * Contains Drupal\Core\PageCache\CacheControlResponseSubscriberBase. */ namespace Drupal\Core\PageCache; use Drupal\Core\Config\ConfigFactory; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; @@ -153,7 +154,9 @@ public function onResponse(FilterResponseEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); - $cacheable = $this->policy->apply($request); + // @todo: Pass the response to the policy and implement the test for + // BinaryFileResponse as a policy rule. + $cacheable = $this->policy->apply($request) && !($response instanceof BinaryFileResponse); if ($cacheable && $this->maxAge > 0 && !$this->isCacheControlCustomized($response)) { $this->setCacheable($response, $request); } diff --git a/core/lib/Drupal/Core/PageCache/PageCacheBase.php b/core/lib/Drupal/Core/PageCache/PageCacheBase.php index ae4d04e..dff1467 100644 --- a/core/lib/Drupal/Core/PageCache/PageCacheBase.php +++ b/core/lib/Drupal/Core/PageCache/PageCacheBase.php @@ -30,6 +30,13 @@ class PageCacheBase implements PageCacheInterface { protected $storage; /** + * Set to FALSE when recording should not be attempted at all. + * + * @var bool + */ + protected $record = TRUE; + + /** * Construct new basic page cache instance. * * @param \Drupal\Core\PageCache\PolicyRuleInterface $policy @@ -50,13 +57,16 @@ public function handle(Request $request) { return $response; } } + else { + $this->record = FALSE; + } } /** * {@inheritdoc} */ public function record(Response $response, Request $request) { - if ($this->policy->apply($request)) { + if ($this->record && $this->policy->apply($request)) { $this->storage->cacheSet($response, $request); }