diff --git a/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php index cd794fe..c3f72af 100644 --- a/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php +++ b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php @@ -20,7 +20,7 @@ class MissingThemeDependencyException extends \Exception { * * @var string */ - public $theme; + protected $theme; /** * Constructs the exception. @@ -35,4 +35,14 @@ public function __construct($message, $theme) { $this->theme = $theme; } + /** + * Gets the machine name of the missing theme. + * + * @return string + * The machine name of the theme that is missing. + */ + public function getMissingThemeName() { + return $this->theme; + } + } diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index 377a43a..329acf6 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -18,7 +18,6 @@ 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; @@ -87,14 +86,6 @@ class DbUpdateController extends ControllerBase { */ protected $postUpdateRegistry; - - /** - * The theme initialization. - * - * @var \Drupal\Core\Theme\ThemeInitializationInterface - */ - protected $themeInitialization; - /** * The theme manager. * @@ -135,8 +126,6 @@ class DbUpdateController extends ControllerBase { * The bare HTML page renderer. * @param \Drupal\Core\Update\UpdateRegistry $post_update_registry * 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 @@ -144,7 +133,7 @@ class DbUpdateController extends ControllerBase { * @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, ThemeManagerInterface $theme_manager, 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, ThemeManagerInterface $theme_manager, ThemeHandlerInterface $theme_handler, ThemeInstallerInterface $theme_installer) { $this->root = $root; $this->keyValueExpirableFactory = $key_value_expirable_factory; $this->cache = $cache; @@ -153,7 +142,6 @@ public function __construct($root, KeyValueExpirableFactoryInterface $key_value_ $this->account = $account; $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; @@ -172,7 +160,6 @@ public static function create(ContainerInterface $container) { $container->get('current_user'), $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') @@ -200,6 +187,8 @@ public function handle($op, Request $request) { drupal_load_updates(); update_fix_compatibility(); + // Make sure that update pages dependencies has been met. + $this->ensureActiveThemeDependencies(); if ($request->query->get('continue')) { $_SESSION['update_ignore_warnings'] = TRUE; @@ -248,9 +237,6 @@ public function handle($op, Request $request) { } $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); } @@ -759,27 +745,26 @@ protected function getModuleUpdates() { return $return; } - /** * Ensures that all the dependencies for active theme has been met. */ protected function ensureActiveThemeDependencies() { - $theme_manager = $this->themeManager; - $theme_handler = $this->themeHandler; - $theme_installer = $this->themeInstaller; + \Drupal::cache('bootstrap')->delete('system_list'); + \Drupal::state()->set('system.theme.data', array()); // 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) { + do { try { - $theme_manager->getActiveTheme(); + $this->themeManager->getActiveTheme(); + break; } catch (MissingThemeDependencyException $e) { - $theme_installer->install([$e->theme]); - $theme_handler->rebuildThemeData(); - $get_active_theme(); + // If this tries to install an unknown theme then it will throw an + // exception. + $theme_installed = $this->themeInstaller->install([$e->getMissingThemeName()]); + $this->themeHandler->rebuildThemeData(); } - }; - $get_active_theme(); + } while ($theme_installed); } } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 69044a1..97f726f 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1810,6 +1810,9 @@ function system_update_8011() { */ function system_update_8012() { $theme_handler = \Drupal::service('theme_handler'); + if ($theme_handler->themeExists('stable')) { + return; + } // Ensure we have fresh info. $theme_handler->rebuildThemeData(); foreach ($theme_handler->listInfo() as $theme) {