diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index b98d28a..80cc52c 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -82,19 +82,21 @@ function _drupal_maintenance_theme() { $theme = $custom_theme; // Find all our ancestor themes and put them in an array. - $base_theme = array(); + // @todo This is just a workaround. Find a better way how to handle themes + // on maintenance pages, see https://www.drupal.org/node/2322619. + // This code is basically a duplicate of + // \Drupal\Core\Theme\ThemeInitialization::getActiveThemeByName. + $base_themes = []; $ancestor = $theme; while ($ancestor && isset($themes[$ancestor]->base_theme)) { - $base_theme[] = $themes[$themes[$ancestor]->base_theme]; + $base_themes[] = $themes[$themes[$ancestor]->base_theme]; $ancestor = $themes[$ancestor]->base_theme; if ($ancestor) { - // Ensure that the base theme is added. + // Ensure that the base theme is added and installed. $theme_handler->addTheme($themes[$ancestor]); } } - // @todo This is just a workaround. Find a better way how to handle themes - // on maintenance pages, see https://www.drupal.org/node/2322619. - \Drupal::theme()->setActiveTheme($theme_init->getActiveTheme($themes[$custom_theme], array_reverse($base_theme))); + \Drupal::theme()->setActiveTheme($theme_init->getActiveTheme($themes[$custom_theme], $base_themes)); // Prime the theme registry. Drupal::service('theme.registry'); } diff --git a/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php b/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php index cd5c1be..a3b54df 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php @@ -57,8 +57,8 @@ public function loadActiveTheme(ActiveTheme $active_theme); * @param \Drupal\Core\Extension\Extension $theme * The theme extension object. * @param \Drupal\Core\Extension\Extension[] $base_themes - * An array of extension objects of base theme and its bases. It is ordered - * by 'oldest first', meaning the top level of the chain will be first. + * An array of extension objects of base theme and its bases. It is ordered + * by 'next parent first', meaning the top level of the chain will be first. * * @return \Drupal\Core\Theme\ActiveTheme * The active theme instance for the passed in $theme. diff --git a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php index 184e07b..dfe920b 100644 --- a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php +++ b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php @@ -41,6 +41,19 @@ protected function setUpSite() { } /** + * {@inheritdoc} + */ + protected function curlExec($curl_options, $redirect = FALSE) { + // Ensure that we see the classy progress CSS on the batch page. + // Batch processing happens as part of HTTP redirects, so we can access the + // HTML of the batch page. + if (strpos($curl_options[CURLOPT_URL], '&id=1&op=do_nojs') !== FALSE) { + $this->assertRaw('themes/classy/css/components/progress.css'); + } + return parent::curlExec($curl_options, $redirect); + } + + /** * Ensures that the exported standard configuration is up to date. */ public function testStandardConfig() { diff --git a/core/tests/Drupal/KernelTests/Core/Theme/MaintenanceThemeTest.php b/core/tests/Drupal/KernelTests/Core/Theme/MaintenanceThemeTest.php new file mode 100644 index 0000000..7cadffa --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/Theme/MaintenanceThemeTest.php @@ -0,0 +1,43 @@ +setSetting('maintenance_theme', 'seven'); + // Get the maintenance theme loaded. + drupal_maintenance_theme(); + + // Do we have an active theme? + $this->assertTrue(\Drupal::theme()->hasActiveTheme()); + + $active_theme = \Drupal::theme()->getActiveTheme(); + $this->assertEquals('seven', $active_theme->getName()); + + $base_themes = $active_theme->getBaseThemes(); + $base_theme_names = array_keys($base_themes); + $this->assertSame(['classy', 'stable'], $base_theme_names); + + // Ensure Classy has the correct base themes and amount of base themes. + $classy_base_themes = $base_themes['classy']->getBaseThemes(); + $classy_base_theme_names = array_keys($classy_base_themes); + $this->assertSame(['stable'], $classy_base_theme_names); + } + +}