From f33b2415bb30137df82df16731ca5fe535db1b96 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org> Date: Wed, 24 Feb 2016 15:14:02 +0900 Subject: [PATCH] Issue #304540 by typhonius, BrockBoland, nabiyllin, RobLoach, marcingy, ravi.khetri, jyotisankar, sudhanshug, jaredsmith, nesta_: Disable themes when theme engine or base theme aren't available --- core/modules/system/src/Controller/SystemController.php | 4 ++-- core/modules/system/src/Tests/System/ThemeTest.php | 4 ++++ .../test_invalid_basetheme_sub.info.yml | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 core/modules/system/tests/themes/test_invalid_basetheme_sub/test_invalid_basetheme_sub.info.yml diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php index 84e6ac57cf40..9829181e86e8 100644 --- a/core/modules/system/src/Controller/SystemController.php +++ b/core/modules/system/src/Controller/SystemController.php @@ -245,8 +245,8 @@ public function themesPage() { // content has a common place in all themes. $theme->incompatible_region = !isset($theme->info['regions']['content']); $theme->incompatible_php = version_compare(phpversion(), $theme->info['php']) < 0; - // Confirmed that the base theme is available. - $theme->incompatible_base = isset($theme->info['base theme']) && !isset($themes[$theme->info['base theme']]); + // Confirm that all base themes are available. + $theme->incompatible_base = (isset($theme->info['base theme']) && !($theme->base_themes === array_filter($theme->base_themes))); // Confirm that the theme engine is available. $theme->incompatible_engine = isset($theme->info['engine']) && !isset($theme->owner); } diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index c2f5a5750685..bea4e391abf9 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -319,6 +319,9 @@ function testSwitchDefaultTheme() { /** * Test themes can't be installed when the base theme or engine is missing. + * + * Include test for themes that have a missing base theme somewhere further up + * the chain than the immediate base theme. */ function testInvalidTheme() { // theme_page_test_system_info_alter() un-hides all hidden themes. @@ -327,6 +330,7 @@ function testInvalidTheme() { $this->container->get('theme_handler')->reset(); $this->drupalGet('admin/appearance'); $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => 'not_real_test_basetheme'))); + $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => 'test_invalid_basetheme'))); $this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => 'not_real_engine'))); // Check for the error text of a theme with the wrong core version. $this->assertText("This theme is not compatible with Drupal 8.x. Check that the .info.yml file contains the correct 'core' value."); diff --git a/core/modules/system/tests/themes/test_invalid_basetheme_sub/test_invalid_basetheme_sub.info.yml b/core/modules/system/tests/themes/test_invalid_basetheme_sub/test_invalid_basetheme_sub.info.yml new file mode 100644 index 000000000000..7b00c1b16fa9 --- /dev/null +++ b/core/modules/system/tests/themes/test_invalid_basetheme_sub/test_invalid_basetheme_sub.info.yml @@ -0,0 +1,6 @@ +name: 'Theme test with valid base theme but no grandparent base theme' +type: theme +description: 'Test theme which has a non-existent base theme in the base chain.' +version: VERSION +core: 8.x +base theme: test_invalid_basetheme -- GitLab