diff --git a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php index 089bc06..97b8f65 100644 --- a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php +++ b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php @@ -67,14 +67,15 @@ public function applies($route_name = '', Route $route = NULL) { */ public function determineActiveTheme(RouteMatchInterface $route_match) { $route = $route_match->getRouteObject() ?: NULL; - - // If no route was found (for example on a 404 page), we still need to - // evaluate all available theme negotiators. - $negotiator_service_ids = ($route && $route->getOption('_theme_negotiators')) ? $route->getOption('_theme_negotiators') : $this->negotiator_service_ids; + $route_theme_negotiator_ids = ($route && $route->getOption('_theme_negotiators')) ? $route->getOption('_theme_negotiators') : array(); + $negotiator_service_ids = $route_theme_negotiator_ids ?: $this->negotiator_service_ids; foreach ($negotiator_service_ids as $service_id) { $negotiator = $this->container->get($service_id); - if (!empty($route) || $negotiator->applies($route_match->getRouteName(), $route)) { + // If no route was found (for example on a 404 page) or no theme + // negotiators were stored on the route, we need to evaluate all available + // theme negotiators. + if ($route_theme_negotiator_ids || $negotiator->applies($route_match->getRouteName(), $route)) { $theme = $negotiator->determineActiveTheme($route_match); if ($theme !== NULL && $this->themeAccess->checkAccess($theme)) { return $theme;