diff --git a/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php index 0c31999..30f52e8 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php @@ -105,7 +105,7 @@ public function setCurrentUser(AccountInterface $current_user = NULL) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('onKernelRequestAccessCheck', 30); + $events[KernelEvents::REQUEST][] = array('onKernelRequestAccessCheck', 29); return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php index 1b665f3..31c10a9 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -107,10 +107,7 @@ public function __construct(StateInterface $state, ConfigFactoryInterface $confi * The Event to process. */ public function onKernelRequestDetermineSiteStatus(GetResponseEvent $event) { - // Check if the site is offline. - $request = $event->getRequest(); - $is_offline = $this->isSiteInMaintenance($request) ? static::SITE_OFFLINE : static::SITE_ONLINE; - $request->attributes->set('_maintenance', $is_offline); + } /** @@ -122,8 +119,12 @@ public function onKernelRequestDetermineSiteStatus(GetResponseEvent $event) { public function onKernelRequestMaintenance(GetResponseEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); + // Check if the site is offline. + $is_offline = $this->isSiteInMaintenance($request) ? static::SITE_OFFLINE : static::SITE_ONLINE; + $request->attributes->set('_maintenance', $is_offline); + // Continue if the site is online and the response is not a redirection. - if ($request->attributes->get('_maintenance') != static::SITE_ONLINE && !($response instanceof RedirectResponse)) { + if ($is_offline != static::SITE_ONLINE && !($response instanceof RedirectResponse)) { // Deliver the 503 page. drupal_maintenance_theme(); $content = Xss::filterAdmin(String::format($this->config->get('system.maintenance')->get('message'), array( @@ -180,7 +181,6 @@ protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = static function getSubscribedEvents() { // In order to change the maintenance status an event subscriber with a // priority between 30 and 40 should be added. - $events[KernelEvents::REQUEST][] = array('onKernelRequestDetermineSiteStatus', 40); $events[KernelEvents::REQUEST][] = array('onKernelRequestMaintenance', 30); return $events; } diff --git a/core/modules/system/tests/modules/menu_test/src/EventSubscriber/MaintenanceModeSubscriber.php b/core/modules/system/tests/modules/menu_test/src/EventSubscriber/MaintenanceModeSubscriber.php index 0b6ae61..4e67e4b 100644 --- a/core/modules/system/tests/modules/menu_test/src/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/modules/system/tests/modules/menu_test/src/EventSubscriber/MaintenanceModeSubscriber.php @@ -36,7 +36,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { * {@inheritdoc} */ public static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('onKernelRequestMaintenance', 35); + $events[KernelEvents::REQUEST][] = array('onKernelRequestMaintenance', 29); return $events; }