core/lib/Drupal/Core/Extension/ThemeExtensionList.php | 18 ++++++++++++++++++ .../big_pipe_test_theme/big_pipe_test_theme.info.yml | 1 + .../block_test_specialchars_theme.info.yml | 1 + .../themes/block_test_theme/block_test_theme.info.yml | 1 + .../themes/color_test_theme/color_test_theme.info.yml | 1 + .../config_translation_test_theme.info.yml | 1 + .../help_topics_test_theme.info.yml | 1 + .../statistics_test_attached.info.yml | 1 + .../test_invalid_core/test_invalid_core.info.yml | 1 + .../test_invalid_region/test_invalid_region.info.yml | 1 + ...e_having_veery_long_name_which_is_too_long.info.yml | 1 + .../test_theme_settings_features.info.yml | 1 + .../test_theme_twig_registry_loader.info.yml | 1 + .../update_test_basetheme.info.yml | 1 + .../themes/user_test_theme/user_test_theme.info.yml | 1 + .../views_test_checkboxes_theme.info.yml | 1 + .../themes/views_test_theme/views_test_theme.info.yml | 1 + .../Drupal/KernelTests/Core/Theme/StableThemeTest.php | 15 +++++++++++++++ core/themes/classy/classy.info.yml | 1 + 19 files changed, 50 insertions(+) diff --git a/core/lib/Drupal/Core/Extension/ThemeExtensionList.php b/core/lib/Drupal/Core/Extension/ThemeExtensionList.php index 3264dc0741..ebb4dc7523 100644 --- a/core/lib/Drupal/Core/Extension/ThemeExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ThemeExtensionList.php @@ -246,6 +246,24 @@ protected function doGetBaseThemes(array $themes, $theme, array $used_themes = [ */ protected function createExtensionInfo(Extension $extension) { $info = parent::createExtensionInfo($extension); + + // In the past, Drupal used to default to the `stable` theme as the base + // theme. Explicitly opting out by specifying `base theme: false` was (and + // still is) possible. However, defaulting to `base theme: stable` prevents + // automatic updates to the next major version of Drupal, since each major + // version has a different version of "the stable theme": + // - for Drupal 8: `stable` + // - for Drupal 9: `stable9` + // - for Drupal 10: `stable10` + // - et cetera + // It is impossible to reliably determine which of these should be selected + // by default, hence we now require the base theme to be explicitly + // specified. + if (!isset($info['base theme'])) { + @trigger_error(sprintf('There is no `base theme` property specified in the %s.info.yml file. The optionality of the `base theme` property is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. All Drupal 8 themes must add `base theme: stable` to their *.info.yml file for them to continue to work as-is in future versions of Drupal. See https://www.drupal.org/node/3066038', $extension->getName()), E_USER_DEPRECATED); + $info['base theme'] = 'stable'; + } + // Remove the default Stable base theme when 'base theme: false' is set in // a theme .info.yml file. if ($info['base theme'] === FALSE) { diff --git a/core/modules/big_pipe/tests/themes/big_pipe_test_theme/big_pipe_test_theme.info.yml b/core/modules/big_pipe/tests/themes/big_pipe_test_theme/big_pipe_test_theme.info.yml index 2b3c842763..6e32b91660 100644 --- a/core/modules/big_pipe/tests/themes/big_pipe_test_theme/big_pipe_test_theme.info.yml +++ b/core/modules/big_pipe/tests/themes/big_pipe_test_theme/big_pipe_test_theme.info.yml @@ -1,5 +1,6 @@ name: 'BigPipe test theme' type: theme +base theme: stable description: 'Theme for testing BigPipe edge cases.' version: VERSION core: 8.x diff --git a/core/modules/block/tests/modules/block_test/themes/block_test_specialchars_theme/block_test_specialchars_theme.info.yml b/core/modules/block/tests/modules/block_test/themes/block_test_specialchars_theme/block_test_specialchars_theme.info.yml index 607451ffbc..f6ce665a3c 100644 --- a/core/modules/block/tests/modules/block_test/themes/block_test_specialchars_theme/block_test_specialchars_theme.info.yml +++ b/core/modules/block/tests/modules/block_test/themes/block_test_specialchars_theme/block_test_specialchars_theme.info.yml @@ -1,5 +1,6 @@ name: '<"Cat" & ''Mouse''>' type: theme +base theme: stable description: 'Theme for testing special characters in block admin.' core: 8.x regions: diff --git a/core/modules/block/tests/modules/block_test/themes/block_test_theme/block_test_theme.info.yml b/core/modules/block/tests/modules/block_test/themes/block_test_theme/block_test_theme.info.yml index 96c76505e1..a3f3fab8df 100644 --- a/core/modules/block/tests/modules/block_test/themes/block_test_theme/block_test_theme.info.yml +++ b/core/modules/block/tests/modules/block_test/themes/block_test_theme/block_test_theme.info.yml @@ -1,5 +1,6 @@ name: 'Block test theme' type: theme +base theme: stable description: 'Theme for testing the block system' version: VERSION core: 8.x diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml index 4fbd9bf3d9..fd68bd8a82 100644 --- a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml +++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml @@ -1,5 +1,6 @@ name: 'Color test theme' type: theme +base theme: stable description: 'Theme for testing the color module' version: VERSION core: 8.x diff --git a/core/modules/config_translation/tests/themes/config_translation_test_theme/config_translation_test_theme.info.yml b/core/modules/config_translation/tests/themes/config_translation_test_theme/config_translation_test_theme.info.yml index f46d8a058f..a27ba76c2c 100644 --- a/core/modules/config_translation/tests/themes/config_translation_test_theme/config_translation_test_theme.info.yml +++ b/core/modules/config_translation/tests/themes/config_translation_test_theme/config_translation_test_theme.info.yml @@ -1,5 +1,6 @@ name: 'Configuration Translation Test Theme' type: theme +base theme: stable description: 'Theme for testing the configuration translation mapper system' version: VERSION core: 8.x diff --git a/core/modules/help_topics/tests/themes/help_topics_test_theme/help_topics_test_theme.info.yml b/core/modules/help_topics/tests/themes/help_topics_test_theme/help_topics_test_theme.info.yml index 70c6951772..d7d3bfe101 100644 --- a/core/modules/help_topics/tests/themes/help_topics_test_theme/help_topics_test_theme.info.yml +++ b/core/modules/help_topics/tests/themes/help_topics_test_theme/help_topics_test_theme.info.yml @@ -1,5 +1,6 @@ name: Test Help Topics type: theme +base theme: stable description: A theme to test help topics. version: VERSION core: 8.x diff --git a/core/modules/statistics/tests/themes/statistics_test_attached/statistics_test_attached.info.yml b/core/modules/statistics/tests/themes/statistics_test_attached/statistics_test_attached.info.yml index 601daf1b53..c3144edef1 100644 --- a/core/modules/statistics/tests/themes/statistics_test_attached/statistics_test_attached.info.yml +++ b/core/modules/statistics/tests/themes/statistics_test_attached/statistics_test_attached.info.yml @@ -1,5 +1,6 @@ name: 'Statistics test attached theme' type: theme +base theme: stable description: 'Theme for testing attached library' version: VERSION core: 8.x diff --git a/core/modules/system/tests/themes/test_invalid_core/test_invalid_core.info.yml b/core/modules/system/tests/themes/test_invalid_core/test_invalid_core.info.yml index 5c369a64e6..3ac1e2017a 100644 --- a/core/modules/system/tests/themes/test_invalid_core/test_invalid_core.info.yml +++ b/core/modules/system/tests/themes/test_invalid_core/test_invalid_core.info.yml @@ -1,5 +1,6 @@ name: 'Theme test with invalid core version' type: theme +base theme: stable description: 'Test theme which has an invalid core version.' version: VERSION core: 7.x diff --git a/core/modules/system/tests/themes/test_invalid_region/test_invalid_region.info.yml b/core/modules/system/tests/themes/test_invalid_region/test_invalid_region.info.yml index 6fef32a21d..02550fa1c9 100644 --- a/core/modules/system/tests/themes/test_invalid_region/test_invalid_region.info.yml +++ b/core/modules/system/tests/themes/test_invalid_region/test_invalid_region.info.yml @@ -1,5 +1,6 @@ name: 'Theme test with missing content region' type: theme +base theme: stable description: 'Test theme which has a non-existent content region.' version: VERSION core: 8.x diff --git a/core/modules/system/tests/themes/test_theme_having_veery_long_name_which_is_too_long/test_theme_having_veery_long_name_which_is_too_long.info.yml b/core/modules/system/tests/themes/test_theme_having_veery_long_name_which_is_too_long/test_theme_having_veery_long_name_which_is_too_long.info.yml index 46432b4f56..ab11132d69 100644 --- a/core/modules/system/tests/themes/test_theme_having_veery_long_name_which_is_too_long/test_theme_having_veery_long_name_which_is_too_long.info.yml +++ b/core/modules/system/tests/themes/test_theme_having_veery_long_name_which_is_too_long/test_theme_having_veery_long_name_which_is_too_long.info.yml @@ -1,4 +1,5 @@ type: theme +base theme: stable core: 8.x name: 'Test theme with a too long name' version: VERSION diff --git a/core/modules/system/tests/themes/test_theme_settings_features/test_theme_settings_features.info.yml b/core/modules/system/tests/themes/test_theme_settings_features/test_theme_settings_features.info.yml index 73ed7e5a41..5e8e9e63af 100644 --- a/core/modules/system/tests/themes/test_theme_settings_features/test_theme_settings_features.info.yml +++ b/core/modules/system/tests/themes/test_theme_settings_features/test_theme_settings_features.info.yml @@ -1,5 +1,6 @@ name: Test features type: theme +base theme: stable core: 8.x description: 'Test theme to test theme settings with limited features.' features: diff --git a/core/modules/system/tests/themes/test_theme_twig_registry_loader/test_theme_twig_registry_loader.info.yml b/core/modules/system/tests/themes/test_theme_twig_registry_loader/test_theme_twig_registry_loader.info.yml index 9ee01c5364..af5ff08a8d 100644 --- a/core/modules/system/tests/themes/test_theme_twig_registry_loader/test_theme_twig_registry_loader.info.yml +++ b/core/modules/system/tests/themes/test_theme_twig_registry_loader/test_theme_twig_registry_loader.info.yml @@ -1,5 +1,6 @@ name: 'Twig registry loader test' type: theme +base theme: stable description: 'Support module for Twig registry loader testing.' version: VERSION core: 8.x diff --git a/core/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info.yml b/core/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info.yml index 9162147909..49daccd3fd 100644 --- a/core/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info.yml +++ b/core/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info.yml @@ -1,5 +1,6 @@ name: 'Update test base theme' type: theme +base theme: stable description: 'Test theme which acts as a base theme for other test subthemes.' version: VERSION core: 8.x diff --git a/core/modules/user/tests/themes/user_test_theme/user_test_theme.info.yml b/core/modules/user/tests/themes/user_test_theme/user_test_theme.info.yml index 79a62e8310..f37cd0c78f 100644 --- a/core/modules/user/tests/themes/user_test_theme/user_test_theme.info.yml +++ b/core/modules/user/tests/themes/user_test_theme/user_test_theme.info.yml @@ -1,5 +1,6 @@ name: 'User Test theme' type: theme +base theme: stable description: 'Theme for testing the available fields in user twig template' version: VERSION core: 8.x diff --git a/core/modules/views/tests/themes/views_test_checkboxes_theme/views_test_checkboxes_theme.info.yml b/core/modules/views/tests/themes/views_test_checkboxes_theme/views_test_checkboxes_theme.info.yml index 50bf73ef44..3b1ce5f2a4 100644 --- a/core/modules/views/tests/themes/views_test_checkboxes_theme/views_test_checkboxes_theme.info.yml +++ b/core/modules/views/tests/themes/views_test_checkboxes_theme/views_test_checkboxes_theme.info.yml @@ -1,5 +1,6 @@ name: Views test checkboxes theme type: theme +base theme: stable description: Theme for testing Views rendering of checkboxes. version: VERSION core: 8.x diff --git a/core/modules/views/tests/themes/views_test_theme/views_test_theme.info.yml b/core/modules/views/tests/themes/views_test_theme/views_test_theme.info.yml index b32f40ab04..ac40cf9c4d 100644 --- a/core/modules/views/tests/themes/views_test_theme/views_test_theme.info.yml +++ b/core/modules/views/tests/themes/views_test_theme/views_test_theme.info.yml @@ -1,5 +1,6 @@ name: Views test theme type: theme +base theme: stable description: Theme for testing Views functionality. version: VERSION core: 8.x diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableThemeTest.php b/core/tests/Drupal/KernelTests/Core/Theme/StableThemeTest.php index 8566b0e8dc..818f1d965a 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/StableThemeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/StableThemeTest.php @@ -46,7 +46,22 @@ protected function setUp() { * Ensures Stable is used by default when no base theme has been defined. */ public function testStableIsDefault() { + $correct_deprecation_error_was_triggered = FALSE; + $previous_error_handler = set_error_handler(function ($severity, $message, $file, $line, $context) use (&$previous_error_handler, &$correct_deprecation_error_was_triggered) { + // Track whether the expected deprecation error was triggered and then + // continue executing code as if nothing happened, to allow the rest of + // the test to still make its assertions. + if ($severity === E_USER_DEPRECATED && $message === 'There is no `base theme` property specified in the test_stable.info.yml file. The optionality of the `base theme` property is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. All Drupal 8 themes must add `base theme: stable` to their *.info.yml file for them to continue to work as-is in future versions of Drupal. See https://www.drupal.org/node/3066038') { + $correct_deprecation_error_was_triggered = TRUE; + return; + } + if ($previous_error_handler) { + return $previous_error_handler($severity, $message, $file, $line, $context); + } + }); + $this->themeHandler->install(['test_stable']); + $this->assertTrue($correct_deprecation_error_was_triggered); $this->config('system.theme')->set('default', 'test_stable')->save(); $theme = $this->themeManager->getActiveTheme(); $base_themes = $theme->getBaseThemeExtensions(); diff --git a/core/themes/classy/classy.info.yml b/core/themes/classy/classy.info.yml index 4685c3faf5..e9ae82b5f9 100644 --- a/core/themes/classy/classy.info.yml +++ b/core/themes/classy/classy.info.yml @@ -1,5 +1,6 @@ name: Classy type: theme +base theme: stable description: 'A base theme with sensible default CSS classes added. Learn how to use Classy as a base theme in the Drupal 8 Theming Guide.' package: Core version: VERSION