diff -u b/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php --- b/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -65,13 +65,21 @@ // If no theme could be negotiated, or if the negotiated theme is not within // the list of enabled themes, fall back to the default theme output of core - // and modules (similar to Stark, but without a theme extension at all). This - // is possible, because loadActiveTheme() always loads the Twig theme engine. + // and modules (like Stark, but without a theme extension at all). This is + // possible, because loadActiveTheme() always loads the Twig theme engine. + // This is desired, because missing or malformed theme configuration should + // not leave the application in a broken state. By falling back to default + // output, the user is able to reconfigure the theme through the UI. + // In addition, kernel tests are expected to operate with no theme and only + // the original theme output of modules by default. if (empty($themes) || !$theme_name || !isset($themes[$theme_name])) { $theme_name = 'core'; // /core/core.info.yml does not actually exist, but is required because // Extension expects a pathname. $active_theme = $this->getActiveTheme(new Extension('theme', 'core/core.info.yml')); + + // Early-return and do not set state, because the initialized $theme_name + // differs from the original $theme_name. return $active_theme; } @@ -126,7 +134,7 @@ /** * {@inheritdoc} */ - public function getActiveTheme(Extension $theme, array $base_themes = array()) { + public function getActiveTheme(Extension $theme, array $base_themes = []) { $theme_path = $theme->getPath(); $values['path'] = $theme_path; diff -u b/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php b/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php --- b/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitializationInterface.php @@ -61,5 +61,5 @@ * The active theme instance for the passed in $theme. */ - public function getActiveTheme(Extension $theme, array $base_themes = array()); + public function getActiveTheme(Extension $theme, array $base_themes = []); } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Theme/DefaultNegotiator.php +++ b/core/lib/Drupal/Core/Theme/DefaultNegotiator.php @@ -43,10 +43,7 @@ public function applies(RouteMatchInterface $route_match) { * {@inheritdoc} */ public function determineActiveTheme(RouteMatchInterface $route_match) { - // @todo Find a proper way to work at the beginning of the installer when - // there is no configuration available yet. One proper way could be to - // provider a custom negotiator during the installer. - return $this->config->get('default') ?: 'stark'; + return $this->config->get('default'); } } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Theme/ThemeManager.php +++ b/core/lib/Drupal/Core/Theme/ThemeManager.php @@ -124,7 +124,7 @@ protected function initTheme(RouteMatchInterface $route_match = NULL) { if (!$route_match) { $route_match = \Drupal::routeMatch(); } - $theme = $this->themeNegotiator->determineActiveTheme($route_match) ?: 'stark'; + $theme = $this->themeNegotiator->determineActiveTheme($route_match); $this->activeTheme = $this->themeInitialization->initTheme($theme); } only in patch2: unchanged: --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -281,6 +281,20 @@ function testEnableModulesTheme() { } /** + * Tests that there is no theme by default. + */ + function testNoThemeByDefault() { + $themes = $this->container->get('config.factory')->get('core.extension')->get('theme'); + $this->assertEqual($themes, array()); + + $extensions = $this->container->get('config.storage')->read('core.extension'); + $this->assertEqual($extensions['theme'], array()); + + $active_theme = $this->container->get('theme.manager')->getActiveTheme(); + $this->assertEqual($active_theme->getName(), 'core'); + } + + /** * Tests that drupal_get_profile() returns NULL. * * As the currently active installation profile is used when installing only in patch2: unchanged: --- a/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php +++ b/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php @@ -36,10 +36,6 @@ public function containerBuild(ContainerBuilder $container) { protected function setUp() { parent::setUp(); $this->installConfig(array('system')); - - // Reset the available themes to test the case of no themes. - $this->extensionConfig()->set('theme', array()); - $this->extensionConfig()->set('disabled.theme', array()); } /** @@ -55,17 +51,8 @@ function testEmpty() { // Rebuilding available themes should always yield results though. $this->assertTrue($this->themeHandler()->rebuildThemeData()['stark'], 'ThemeHandler::rebuildThemeData() yields all available themes.'); - try { - // theme_get_setting() should fail, as no theme is available. - $this->assertIdentical(theme_get_setting('features.favicon'), TRUE); - $this->fail('No theme should lead to an exception'); - } - catch (\RuntimeException $e) { - $this->assertEqual($e->getMessage(), 'No theme is enabled.'); - } - catch (\Exception $e) { - $this->fail('The runtime exception should be thrown.'); - } + // theme_get_setting() should return global default theme settings. + $this->assertIdentical(theme_get_setting('features.favicon'), TRUE); } /**