diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index db6d1ea2002929cfde2e78d2596a4fa9156fa95c..a6e918f0bed9d7a47de29f8397c38e3fe27d5530 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1611,21 +1611,13 @@ function install_profile_modules(&$install_state) { * An array of information about the current installation state. */ function install_profile_themes(&$install_state) { - $theme_handler = \Drupal::service('theme_handler'); - - // ThemeHandler::install() resets the current list of themes. The theme used - // in the installer is not necessarily in the list of themes to install, so - // retain the current list. - // @see _drupal_maintenance_theme() - $current_themes = $theme_handler->listInfo(); - // Install the themes specified by the installation profile. $themes = $install_state['profile_info']['themes']; - $theme_handler->install($themes); + \Drupal::service('theme_handler')->install($themes); - foreach ($current_themes as $theme) { - $theme_handler->addTheme($theme); - } + // Ensure that the install profile's theme is used. + // @see _drupal_maintenance_theme() + \Drupal::service('theme.manager')->resetActiveTheme(); } /** @@ -1644,6 +1636,10 @@ function install_install_profile(&$install_state) { // optional configuration whose dependencies can be met at this point removes // any disparities that this creates. \Drupal::service('config.installer')->installOptionalConfig(); + + // Ensure that the install profile's theme is used. + // @see _drupal_maintenance_theme() + \Drupal::service('theme.manager')->resetActiveTheme(); } /** diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index d63ce1be6c748831800849903047ff4d96dc4215..16779afd1962a1b6f90b904016e0ac4fddf77992 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -68,11 +68,10 @@ function _drupal_maintenance_theme() { // installed, retrieve all available themes. /** @var \Drupal\Core\Theme\ThemeInitialization $theme_init */ $theme_init = \Drupal::service('theme.initialization'); + $theme_handler = \Drupal::service('theme_handler'); if (empty($themes) || !isset($themes[$custom_theme])) { - $theme_handler = \Drupal::service('theme_handler'); $themes = $theme_handler->rebuildThemeData(); $theme_handler->addTheme($themes[$custom_theme]); - \Drupal::theme()->setActiveTheme($theme_init->getActiveTheme($themes[$custom_theme], array())); } // \Drupal\Core\Extension\ThemeHandlerInterface::listInfo() triggers a @@ -86,8 +85,12 @@ function _drupal_maintenance_theme() { $base_theme = array(); $ancestor = $theme; while ($ancestor && isset($themes[$ancestor]->base_theme)) { - $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme]; + $base_theme[] = $themes[$themes[$ancestor]->base_theme]; $ancestor = $themes[$ancestor]->base_theme; + if ($ancestor) { + // Ensure that the base theme is added. + $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. diff --git a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a19ab6c83109f322472daee85a988a8b326ec987 --- /dev/null +++ b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php @@ -0,0 +1,46 @@ +<?php + +/** + * @file + * Contains \Drupal\system\Tests\Installer\StandardInstallerTest. + */ + +namespace Drupal\system\Tests\Installer; + +use Drupal\simpletest\InstallerTestBase; + +/** + * Tests the interactive installer installing the standard profile. + * + * @group Installer + */ +class StandardInstallerTest extends InstallerTestBase { + + /** + * {@inheritdoc} + */ + protected $profile = 'standard'; + + /** + * Ensures that the user page is available after installation. + */ + public function testInstaller() { + // Verify that the confirmation message appears. + require_once \Drupal::root() . '/core/includes/install.inc'; + $this->assertRaw(t('Congratulations, you installed @drupal!', array( + '@drupal' => drupal_install_profile_distribution_name(), + ))); + } + + /** + * {@inheritdoc} + */ + protected function setUpSite() { + // Test that the correct theme is being used. + $this->assertNoRaw('bartik'); + $this->assertRaw('themes/seven/css/theme/install-page.css'); + parent::setUpSite(); + } + + +}