reverted: --- b/core/includes/theme.maintenance.inc +++ a/core/includes/theme.maintenance.inc @@ -6,7 +6,6 @@ */ use Drupal\Component\Utility\Unicode; -use Drupal\Core\Theme\MissingThemeDependencyException; use Drupal\Core\Site\Settings; /** @@ -32,7 +31,37 @@ require_once __DIR__ . '/database.inc'; Unicode::check(); + // Install and update pages are treated differently to prevent theming overrides. + if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) { + if (drupal_installation_attempted()) { + $custom_theme = $GLOBALS['install_state']['theme']; + } + else { + $custom_theme = Settings::get('maintenance_theme', 'seven'); + } + } + else { + // Use the maintenance theme if specified, otherwise attempt to use the + // default site theme. + try { + $custom_theme = Settings::get('maintenance_theme', ''); + if (!$custom_theme) { + $config = \Drupal::config('system.theme'); + $custom_theme = $config->get('default'); + } + } + catch (\Exception $e) { + // Whatever went wrong (often a database connection problem), we are + // about to fall back to a sensible theme so there is no need for special + // handling. + } + if (!$custom_theme) { + // We have been unable to identify the configured theme, so fall back to + // a safe default. Bartik is reasonably user friendly and fairly generic. + $custom_theme = 'bartik'; + } + } + - $custom_theme = _drupal_get_maintenance_theme(); $themes = \Drupal::service('theme_handler')->listInfo(); // If no themes are installed yet, or if the requested custom theme is not @@ -105,45 +134,3 @@ } $variables['messages'] = $messages; } - -/** - * Gets the theme used for maintenance page. - * - * @return string - * The name of the maintenance page theme. - */ -function _drupal_get_maintenance_theme() { - // Install and update pages are treated differently to prevent theming - // overrides. - if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) { - if (drupal_installation_attempted()) { - $custom_theme = $GLOBALS['install_state']['theme']; - } - else { - $custom_theme = Settings::get('maintenance_theme', 'seven'); - } - } - else { - // Use the maintenance theme if specified, otherwise attempt to use the - // default site theme. - try { - $custom_theme = Settings::get('maintenance_theme', ''); - if (!$custom_theme) { - $config = \Drupal::config('system.theme'); - $custom_theme = $config->get('default'); - } - } - catch (\Exception $e) { - // Whatever went wrong (often a database connection problem), we are - // about to fall back to a sensible theme so there is no need for special - // handling. - } - if (!$custom_theme) { - // We have been unable to identify the configured theme, so fall back to - // a safe default. Bartik is reasonably user friendly and fairly generic. - $custom_theme = 'bartik'; - } - } - - return $custom_theme; -} diff -u b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php --- b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php +++ b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php @@ -11,6 +11,7 @@ * Exception to be thrown when base theme for installed theme is not installed. * * @see \Drupal\Core\Theme\ThemeInitialization::getActiveThemeByName(). + * @see \Drupal\system\Controller\DbUpdateController::ensureActiveThemeDependencies(). */ class MissingThemeDependencyException extends \Exception { diff -u b/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php --- b/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -17,7 +17,9 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\Site\Settings; use Drupal\Core\State\StateInterface; +use Drupal\Core\Theme\MissingThemeDependencyException; use Drupal\Core\Theme\ThemeInitializationInterface; +use Drupal\Core\Theme\ThemeManagerInterface; use Drupal\Core\Update\UpdateRegistry; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -94,6 +96,13 @@ protected $themeInitialization; /** + * The theme manager. + * + * @var \Drupal\Core\Theme\ThemeManagerInterface + */ + protected $themeManager; + + /** * The theme handler. * * @var \Drupal\Core\Extension\ThemeHandlerInterface @@ -128,10 +137,14 @@ * The post update registry. * @param \Drupal\Core\Theme\ThemeInitializationInterface $theme_initialization * The theme initialization. + * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager + * The theme manager. * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler. + * @param \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer + * The theme installer. */ - public function __construct($root, KeyValueExpirableFactoryInterface $key_value_expirable_factory, CacheBackendInterface $cache, StateInterface $state, ModuleHandlerInterface $module_handler, AccountInterface $account, BareHtmlPageRendererInterface $bare_html_page_renderer, UpdateRegistry $post_update_registry, ThemeInitializationInterface $theme_initialization, ThemeHandlerInterface $theme_handler, ThemeInstallerInterface $theme_installer) { + public function __construct($root, KeyValueExpirableFactoryInterface $key_value_expirable_factory, CacheBackendInterface $cache, StateInterface $state, ModuleHandlerInterface $module_handler, AccountInterface $account, BareHtmlPageRendererInterface $bare_html_page_renderer, UpdateRegistry $post_update_registry, ThemeInitializationInterface $theme_initialization, ThemeManagerInterface $theme_manager, ThemeHandlerInterface $theme_handler, ThemeInstallerInterface $theme_installer) { $this->root = $root; $this->keyValueExpirableFactory = $key_value_expirable_factory; $this->cache = $cache; @@ -141,6 +154,7 @@ $this->bareHtmlPageRenderer = $bare_html_page_renderer; $this->postUpdateRegistry = $post_update_registry; $this->themeInitialization = $theme_initialization; + $this->themeManager = $theme_manager; $this->themeHandler = $theme_handler; $this->themeInstaller = $theme_installer; } @@ -159,6 +173,7 @@ $container->get('bare_html_page_renderer'), $container->get('update.post_update_registry'), $container->get('theme.initialization'), + $container->get('theme.manager'), $container->get('theme_handler'), $container->get('theme_installer') ); @@ -233,6 +248,9 @@ } $title = isset($output['#title']) ? $output['#title'] : $this->t('Drupal database update'); + // Make sure that update pages dependencies has been met. + $this->ensureActiveThemeDependencies(); + return $this->bareHtmlPageRenderer->renderBarePage($output, $title, 'maintenance_page', $regions); } @@ -743,26 +761,25 @@ /** - * Ensures that all the dependencies for theme has been met before proceeding. + * Ensures that all the dependencies for active theme has been met. */ - protected function ensureThemeDependencies() { - $custom_theme = _drupal_get_maintenance_theme(); - $theme_init = $this->themeInitialization; + protected function ensureActiveThemeDependencies() { + $theme_manager = $this->themeManager; $theme_handler = $this->themeHandler; - $themes = $theme_handler->listInfo(); $theme_installer = $this->themeInstaller; - // Ensure that at least the maintenance page has a working theme where all of - // the parent themes have been enabled. - $get_active_theme = function () use ($theme_init, $themes, $theme_handler, $theme_installer, $custom_theme, &$get_active_theme) { + // Ensure that at least the maintenance page has a working theme where all + // of the parent themes have been enabled. + $get_active_theme = function () use ($theme_manager, $theme_handler, $theme_installer, &$get_active_theme) { try { - return $theme_init->getActiveTheme($themes[$custom_theme]); + $theme_manager->getActiveTheme(); } catch (MissingThemeDependencyException $e) { $theme_installer->install([$e->theme]); - $themes = $theme_handler->rebuildThemeData(); - return $get_active_theme(); + $theme_handler->rebuildThemeData(); + $get_active_theme(); } }; + $get_active_theme(); } }