From 4af66535e449ff52db8e5a62fe2aec94ef0134a0 Mon Sep 17 00:00:00 2001 From: catch Date: Mon, 27 Jan 2020 10:58:40 +0000 Subject: [PATCH] Issue #3098250 by alexpott, longwave, Wim Leers, lauriii: Remove all @deprecated code in \Drupal\Core\Extension --- .../Core/Extension/InfoParserDynamic.php | 18 ------- .../Core/Extension/ThemeExtensionList.php | 18 ++----- .../Kernel/Extension/ModuleHandlerTest.php | 38 -------------- ...g_install_profile_dependencies_bc.info.yml | 10 ---- .../InstallProfileDependenciesBcTest.php | 49 ------------------- ...ationTest.php => BaseThemeMissingTest.php} | 39 +++++---------- .../test_missing_base_theme.info.yml | 4 ++ .../test_missing_base_theme.theme | 6 +++ 8 files changed, 24 insertions(+), 158 deletions(-) delete mode 100644 core/profiles/testing_install_profile_dependencies_bc/testing_install_profile_dependencies_bc.info.yml delete mode 100644 core/tests/Drupal/FunctionalTests/Installer/InstallProfileDependenciesBcTest.php rename core/tests/Drupal/KernelTests/Core/Theme/{BaseThemeDefaultDeprecationTest.php => BaseThemeMissingTest.php} (58%) create mode 100644 core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.info.yml create mode 100644 core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.theme diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index 2e1dae399d3f..73cadab82e24 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -102,24 +102,6 @@ class InfoParserDynamic implements InfoParserInterface { if (isset($parsed_info['version']) && $parsed_info['version'] === 'VERSION') { $parsed_info['version'] = \Drupal::VERSION; } - // Special backwards compatible handling profiles and their 'dependencies' - // key. - if ($parsed_info['type'] === 'profile' && isset($parsed_info['dependencies']) && !array_key_exists('install', $parsed_info)) { - // Only trigger the deprecation message if we are actually using the - // profile with the missing 'install' key. This avoids triggering the - // deprecation when scanning all the available install profiles. - global $install_state; - if (isset($install_state['parameters']['profile'])) { - $pattern = '@' . preg_quote(DIRECTORY_SEPARATOR . $install_state['parameters']['profile'] . '.info.yml') . '$@'; - if (preg_match($pattern, $filename)) { - @trigger_error("The install profile $filename only implements a 'dependencies' key. As of Drupal 8.6.0 profile's support a new 'install' key for modules that should be installed but not depended on. See https://www.drupal.org/node/2952947.", E_USER_DEPRECATED); - } - } - // Move dependencies to install so that if a profile has both - // dependencies and install then dependencies are real. - $parsed_info['install'] = $parsed_info['dependencies']; - $parsed_info['dependencies'] = []; - } } return $parsed_info; } diff --git a/core/lib/Drupal/Core/Extension/ThemeExtensionList.php b/core/lib/Drupal/Core/Extension/ThemeExtensionList.php index 5722d1c2feaa..8da8084578f4 100644 --- a/core/lib/Drupal/Core/Extension/ThemeExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ThemeExtensionList.php @@ -247,24 +247,12 @@ class ThemeExtensionList extends ExtensionList { 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 may have a different version of "the stable theme", for example: - // - for Drupal 8: `stable` - // - for Drupal 9: `stable9` - // - for Drupal 10: `stable10` - // - et cetera - // It is impossible to reliably determine which should be used 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. Drupal 9 requires the `base theme` property to be specified. See https://www.drupal.org/node/3066038', $extension->getName()), E_USER_DEPRECATED); - $info['base theme'] = 'stable'; + throw new InfoParserException('Missing required key (base_theme) in ' . $extension->getExtensionPathname() . '/' . $extension->getExtensionFilename()); } - // Remove the default Stable base theme when 'base theme: false' is set in - // a theme .info.yml file. + // Remove the base theme when 'base theme: false' is set in a theme + // .info.yml file. if ($info['base theme'] === FALSE) { unset($info['base theme']); } diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index 698de170a65a..39a7331b5709 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -150,44 +150,6 @@ class ModuleHandlerTest extends KernelTestBase { $this->assertIdentical($enable_order, ['help', 'config', 'color']); } - /** - * Tests uninstalling a module that is a "dependency" of a profile. - * - * Note this test does not trigger the deprecation error because of static - * caching in \Drupal\Core\Extension\InfoParser::parse(). - * - * @group legacy - */ - public function testUninstallProfileDependencyBC() { - $profile = 'testing_install_profile_dependencies_bc'; - $dependency = 'dblog'; - $this->setInstallProfile($profile); - // Prime the drupal_get_filename() static cache with the location of the - // testing profile as it is not the currently active profile and we don't - // yet have any cached way to retrieve its location. - // @todo Remove as part of https://www.drupal.org/node/2186491 - drupal_get_filename('profile', $profile, 'core/profiles/' . $profile . '/' . $profile . '.info.yml'); - $this->enableModules(['module_test', $profile]); - - $data = \Drupal::service('extension.list.module')->getList(); - $this->assertFalse(isset($data[$profile]->requires[$dependency])); - $this->assertContains($dependency, $data[$profile]->info['install']); - - $this->moduleInstaller()->install([$dependency]); - $this->assertTrue($this->moduleHandler()->moduleExists($dependency)); - - // Uninstall the profile module "dependency". - $result = $this->moduleInstaller()->uninstall([$dependency]); - $this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.'); - $this->assertFalse($this->moduleHandler()->moduleExists($dependency)); - $this->assertEqual(drupal_get_installed_schema_version($dependency), SCHEMA_UNINSTALLED, "$dependency module was uninstalled."); - - // Verify that the installation profile itself was not uninstalled. - $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: []; - $this->assertTrue(in_array($dependency, $uninstalled_modules), "$dependency module is in the list of uninstalled modules."); - $this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.'); - } - /** * Tests uninstalling a module installed by a profile. */ diff --git a/core/profiles/testing_install_profile_dependencies_bc/testing_install_profile_dependencies_bc.info.yml b/core/profiles/testing_install_profile_dependencies_bc/testing_install_profile_dependencies_bc.info.yml deleted file mode 100644 index 7a99743b0817..000000000000 --- a/core/profiles/testing_install_profile_dependencies_bc/testing_install_profile_dependencies_bc.info.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: 'Testing install profile dependencies BC layer' -type: profile -description: 'Profile for testing BC layer for profile dependencies.' -version: VERSION -hidden: true -dependencies: - - dblog - - ban -themes: - - classy diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallProfileDependenciesBcTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallProfileDependenciesBcTest.php deleted file mode 100644 index 2f3890efc014..000000000000 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallProfileDependenciesBcTest.php +++ /dev/null @@ -1,49 +0,0 @@ -drupalCreateUser(['administer modules']); - $this->drupalLogin($user); - $this->drupalGet('admin/modules/uninstall'); - $this->getSession()->getPage()->checkField('uninstall[ban]'); - $this->getSession()->getPage()->checkField('uninstall[dblog]'); - $this->click('#edit-submit'); - // Click the confirm button. - $this->click('#edit-submit'); - $this->assertSession()->responseContains('The selected modules have been uninstalled.'); - $this->assertSession()->responseContains('No modules are available to uninstall.'); - // We've uninstalled modules therefore we need to rebuild the container in - // the test runner. - $this->rebuildContainer(); - $module_handler = $this->container->get('module_handler'); - $this->assertFalse($module_handler->moduleExists('ban')); - $this->assertFalse($module_handler->moduleExists('dblog')); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Theme/BaseThemeDefaultDeprecationTest.php b/core/tests/Drupal/KernelTests/Core/Theme/BaseThemeMissingTest.php similarity index 58% rename from core/tests/Drupal/KernelTests/Core/Theme/BaseThemeDefaultDeprecationTest.php rename to core/tests/Drupal/KernelTests/Core/Theme/BaseThemeMissingTest.php index 176671183679..905e5afb8bc0 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/BaseThemeDefaultDeprecationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/BaseThemeMissingTest.php @@ -5,17 +5,18 @@ namespace Drupal\KernelTests\Core\Theme; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Extension\InfoParser; +use Drupal\Core\Extension\InfoParserException; use Drupal\Core\Extension\InfoParserInterface; use Drupal\Core\Extension\ThemeExtensionList; use Drupal\KernelTests\KernelTestBase; use org\bovigo\vfs\vfsStream; /** - * Tests the behavior of the Stable theme. + * Tests the behavior of a theme when base_theme info key is missing. * * @group Theme */ -class BaseThemeDefaultDeprecationTest extends KernelTestBase { +class BaseThemeMissingTest extends KernelTestBase { /** * {@inheritdoc} @@ -29,13 +30,6 @@ class BaseThemeDefaultDeprecationTest extends KernelTestBase { */ protected $themeInstaller; - /** - * The theme manager. - * - * @var \Drupal\Core\Theme\ThemeManagerInterface - */ - protected $themeManager; - /** * {@inheritdoc} */ @@ -43,7 +37,6 @@ class BaseThemeDefaultDeprecationTest extends KernelTestBase { parent::setUp(); $this->themeInstaller = $this->container->get('theme_installer'); - $this->themeManager = $this->container->get('theme.manager'); } /** @@ -65,35 +58,25 @@ class BaseThemeDefaultDeprecationTest extends KernelTestBase { $vfs_root = vfsStream::setup('core'); vfsStream::create([ 'themes' => [ - 'test_stable' => [ - 'test_stable.info.yml' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_stable/test_stable.info.yml'), - 'test_stable.theme' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_stable/test_stable.theme'), - ], - 'stable' => [ - 'stable.info.yml' => file_get_contents(DRUPAL_ROOT . '/core/themes/stable/stable.info.yml'), - 'stable.theme' => file_get_contents(DRUPAL_ROOT . '/core/themes/stable/stable.theme'), + 'test_missing_base_theme' => [ + 'test_missing_base_theme.info.yml' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.info.yml'), + 'test_missing_base_theme.theme' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.theme'), ], ], ], $vfs_root); } /** - * Ensures Stable is used by default when no base theme has been defined. - * - * @group legacy - * @expectedDeprecation 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. Drupal 9 requires the `base theme` property to be specified. See https://www.drupal.org/node/3066038 + * Tests exception is thrown. */ - public function testStableIsDefault() { + public function testMissingBaseThemeException() { $this->container->get('extension.list.theme') ->setExtensionDiscovery(new ExtensionDiscovery('vfs://core')) ->setInfoParser(new VfsInfoParser('vfs:/')); - $this->themeInstaller->install(['test_stable']); - $this->config('system.theme')->set('default', 'test_stable')->save(); - $theme = $this->themeManager->getActiveTheme(); - $base_themes = $theme->getBaseThemeExtensions(); - $base_theme = reset($base_themes); - $this->assertTrue($base_theme->getName() == 'stable', "Stable theme is the base theme if a theme hasn't decided to opt out."); + $this->expectException(InfoParserException::class); + $this->expectExceptionMessage('Missing required key (base_theme) in themes/test_missing_base_theme/test_missing_base_theme.theme/test_missing_base_theme.theme'); + $this->themeInstaller->install(['test_missing_base_theme']); } } diff --git a/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.info.yml b/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.info.yml new file mode 100644 index 000000000000..68549f58a78b --- /dev/null +++ b/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.info.yml @@ -0,0 +1,4 @@ +name: Test Missing Base Theme +type: theme +description: A theme to test missing base theme. +version: VERSION diff --git a/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.theme b/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.theme new file mode 100644 index 000000000000..3150f8b2f469 --- /dev/null +++ b/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.theme @@ -0,0 +1,6 @@ +