diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index e135ff2197..3faff7751d 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -12,7 +12,7 @@ class InfoParserDynamic implements InfoParserInterface { /** - * The earliest version of Drupal that supports the 'core_dependency' key. + * The earliest Drupal version that supports the 'core_version_requirement'. */ const FIRST_CORE_DEPENDENCY_SUPPORTED_VERSION = '8.7.7'; @@ -57,34 +57,35 @@ public function parse($filename) { if (!empty($missing_keys)) { throw new InfoParserException('Missing required keys (' . implode(', ', $missing_keys) . ') in ' . $filename); } - if (!isset($parsed_info['core']) && !isset($parsed_info['core_dependency'])) { - throw new InfoParserException("The 'core' or the 'core_dependency' key must be present in " . $filename); + if (!isset($parsed_info['core']) && !isset($parsed_info['core_version_requirement'])) { + throw new InfoParserException("The 'core' or the 'core_version_requirement' key must be present in " . $filename); } if (isset($parsed_info['core']) && !preg_match("/^\d\.x$/", $parsed_info['core'])) { throw new InfoParserException("Invalid 'core' value \"{$parsed_info['core']}\" in " . $filename); } - if (isset($parsed_info['core_dependency'])) { - $supports_pre_core_dependency_version = static::isConstraintSatisfiedByPreCoreDependencyCoreVersion($parsed_info['core_dependency']); - // If the 'core_dependency' constraint does not satisfy any Drupal 8 - // versions before 8.7.7 then 'core' cannot be set or it will + if (isset($parsed_info['core_version_requirement'])) { + $supports_pre_core_dependency_version = static::isConstraintSatisfiedByPreCoreDependencyCoreVersion($parsed_info['core_version_requirement']); + // If the 'core_version_requirement' constraint does not satisfy any + // Drupal 8 versions before 8.7.7 then 'core' cannot be set or it will // effectively support all versions of Drupal 8 because - // 'core_dependency' will be ignored in previous versions. + // 'core_version_requirement' will be ignored in previous versions. if (!$supports_pre_core_dependency_version && isset($parsed_info['core'])) { - throw new InfoParserException("The 'core_dependency' constraint ({$parsed_info['core_dependency']}) requires the 'core' not be set in " . $filename); + throw new InfoParserException("The 'core_version_requirement' constraint ({$parsed_info['core_version_requirement']}) requires the 'core' not be set in " . $filename); } - // 'core_dependency' can not be used to specify Drupal 8 versions before - // 8.7.7 because these versions do not use the 'core_dependency' key. - // Do not throw the exception if the constraint also is satisfied by - // 8.0.0-alpha1 to allow constraints such as '^8' or '^8 || ^9'. - if ($supports_pre_core_dependency_version && !static::satisfies('8.0.0-alpha1', $parsed_info['core_dependency'])) { - throw new InfoParserException("The 'core_dependency' can not be used to specify compatibility specific version before " . static::FIRST_CORE_DEPENDENCY_SUPPORTED_VERSION . " in $filename"); + // 'core_version_requirement' can not be used to specify Drupal 8 + // versions before 8.7.7 because these versions do not use the + // 'core_version_requirement' key. Do not throw the exception if the + // constraint also is satisfied by 8.0.0-alpha1 to allow constraints + // such as '^8' or '^8 || ^9'. + if ($supports_pre_core_dependency_version && !static::satisfies('8.0.0-alpha1', $parsed_info['core_version_requirement'])) { + throw new InfoParserException("The 'core_version_requirement' can not be used to specify compatibility specific version before " . static::FIRST_CORE_DEPENDENCY_SUPPORTED_VERSION . " in $filename"); } } // Determine if the extension is compatible with the current version of // Drupal core. try { - $parsed_info['core_incompatible'] = !static::satisfies(\Drupal::VERSION, $parsed_info['core_dependency'] ?? $parsed_info['core']); + $parsed_info['core_incompatible'] = !static::satisfies(\Drupal::VERSION, $parsed_info['core_version_requirement'] ?? $parsed_info['core']); } catch (\UnexpectedValueException $exception) { $parsed_info['core_incompatible'] = TRUE; @@ -125,16 +126,16 @@ protected function getRequiredKeys() { } /** - * Determines if a constraint is satisfied by core without 'core_dependency'. + * Determines if a constraint is satisfied by earlier versions of Drupal. * * @param string $constraint * A core semantic version constraint. * * @return bool * TRUE if the constraint is satisfied by a core version that does not - * support the 'core_dependency' key in info.yml files. + * support the 'core_version_requirement' key in info.yml files. */ - static protected function isConstraintSatisfiedByPreCoreDependencyCoreVersion($constraint) { + protected static function isConstraintSatisfiedByPreCoreDependencyCoreVersion($constraint) { static $evaluated_constraints = []; if (!isset($evaluated_constraints[$constraint])) { foreach (range(0, 7) as $minor) { diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index 9d73b3e43b..af10611596 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -300,7 +300,7 @@ protected function buildRow(array $modules, Extension $module, $distribution) { '@core_version' => \Drupal::VERSION, ]); $row['#requires']['core'] = $this->t('Drupal Core (@core_requirement) (incompatible with version @core_version)', [ - '@core_requirement' => $module->info['core_dependency'] ?? $module->info['core'], + '@core_requirement' => $module->info['core_version_requirement'] ?? $module->info['core'], '@core_version' => \Drupal::VERSION, ]); } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 96d8a65608..3a5d6b5dba 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -294,7 +294,7 @@ function template_preprocess_system_themes_page(&$variables) { // Make sure to provide feedback on compatibility. $current_theme['incompatible'] = ''; if (!empty($theme->incompatible_core)) { - $current_theme['incompatible'] = t("This theme is not compatible with Drupal @core_version. Check that the .info.yml file contains a compatible 'core' or 'core_dependency' value.", ['@core_version' => \Drupal::VERSION]); + $current_theme['incompatible'] = t("This theme is not compatible with Drupal @core_version. Check that the .info.yml file contains a compatible 'core' or 'core_version_requirement' value.", ['@core_version' => \Drupal::VERSION]); } elseif (!empty($theme->incompatible_region)) { $current_theme['incompatible'] = t("This theme is missing a 'content' region."); diff --git a/core/modules/system/tests/modules/system_core_incompatible_semver_test/system_core_incompatible_semver_test.info.yml b/core/modules/system/tests/modules/system_core_incompatible_semver_test/system_core_incompatible_semver_test.info.yml index 850c9344e0..152d2a66ec 100644 --- a/core/modules/system/tests/modules/system_core_incompatible_semver_test/system_core_incompatible_semver_test.info.yml +++ b/core/modules/system/tests/modules/system_core_incompatible_semver_test/system_core_incompatible_semver_test.info.yml @@ -3,4 +3,4 @@ type: module description: 'Support module for testing core incompatible semver.' package: Testing version: 1.0.0 -core_dependency: ^7 +core_version_requirement: ^7 diff --git a/core/modules/system/tests/modules/system_core_semver_test/system_core_semver_test.info.yml b/core/modules/system/tests/modules/system_core_semver_test/system_core_semver_test.info.yml index 5ca06ba0af..47eec87f48 100644 --- a/core/modules/system/tests/modules/system_core_semver_test/system_core_semver_test.info.yml +++ b/core/modules/system/tests/modules/system_core_semver_test/system_core_semver_test.info.yml @@ -3,4 +3,4 @@ type: module description: 'Support module for testing core using semver.' package: Testing version: 1.0.0 -core_dependency: ^8 +core_version_requirement: ^8 diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module index b14262802c..7f0ba88cd0 100644 --- a/core/modules/system/tests/modules/system_test/system_test.module +++ b/core/modules/system/tests/modules/system_test/system_test.module @@ -62,10 +62,6 @@ function system_test_system_info_alter(&$info, Extension $file, $type) { } } - if (($core_requirement = \Drupal::state()->get('dependency_test.core_version_requirement')) && $file->getName() === 'common_test') { - $info['core_dependency'] = $core_requirement; - } - // Make the system_dependencies_test visible by default. if ($file->getName() == 'system_dependencies_test') { $info['hidden'] = FALSE; diff --git a/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.info.yml b/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.info.yml index 71da4cbcd0..74e908530d 100644 --- a/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.info.yml +++ b/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.info.yml @@ -3,4 +3,4 @@ type: module description: 'Support module for update testing with core semver value.' package: Testing version: VERSION -core_dependency: ^8 +core_version_requirement: ^8 diff --git a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php index c524eebb51..1e1b2fc579 100644 --- a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php +++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php @@ -70,7 +70,7 @@ public function testModulesListFormWithInvalidInfoFile() { // Confirm that the error message is shown. $this->assertSession() - ->pageTextContains("The 'core' or the 'core_dependency' key must be present in " . $path . '/broken.info.yml'); + ->pageTextContains("The 'core' or the 'core_version_requirement' key must be present in " . $path . '/broken.info.yml'); // Check that the module filter text box is available. $this->assertTrue($this->xpath('//input[@name="text"]')); diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php index e7ee2abfc6..adb8da9a56 100644 --- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php +++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php @@ -108,12 +108,12 @@ public function testIncompatiblePhpVersionDependency() { public function testCoreCompatibility() { $assert_session = $this->assertSession(); - // Test incompatible 'core_dependency'. + // Test incompatible 'core_version_requirement'. $this->drupalGet('admin/modules'); $assert_session->fieldDisabled('modules[system_incompatible_core_version_test_1x][enable]'); $assert_session->fieldDisabled('modules[system_core_incompatible_semver_test][enable]'); - // Test compatible 'core_dependency' and compatible 'core'. + // Test compatible 'core_version_requirement' and compatible 'core'. $this->drupalGet('admin/modules'); $assert_session->fieldEnabled('modules[common_test][enable]'); $assert_session->fieldEnabled('modules[system_core_semver_test][enable]'); diff --git a/core/modules/system/tests/src/Functional/System/ThemeTest.php b/core/modules/system/tests/src/Functional/System/ThemeTest.php index 8c89f0c8a5..1964e4172e 100644 --- a/core/modules/system/tests/src/Functional/System/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php @@ -369,7 +369,7 @@ public function testInvalidTheme() { $this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', ['@theme_engine' => 'not_real_engine'])); // Check for the error text of a theme with the wrong core version // using 7.x and ^7. - $incompatible_core_message = 'This theme is not compatible with Drupal ' . \Drupal::VERSION . ". Check that the .info.yml file contains a compatible 'core' or 'core_dependency' value."; + $incompatible_core_message = 'This theme is not compatible with Drupal ' . \Drupal::VERSION . ". Check that the .info.yml file contains a compatible 'core' or 'core_version_requirement' value."; $this->assertThemeIncompatibleText('Theme test with invalid core version', $incompatible_core_message); $this->assertThemeIncompatibleText('Theme test with invalid semver core version', $incompatible_core_message); // Check for the error text of a theme without a content region. diff --git a/core/modules/system/tests/themes/test_core_semver/test_core_semver.info.yml b/core/modules/system/tests/themes/test_core_semver/test_core_semver.info.yml index 6802118b78..4645badc2a 100644 --- a/core/modules/system/tests/themes/test_core_semver/test_core_semver.info.yml +++ b/core/modules/system/tests/themes/test_core_semver/test_core_semver.info.yml @@ -2,4 +2,4 @@ name: 'Theme test with semver core version' type: theme description: 'Test theme which has semver core version.' version: VERSION -core_dependency: ^8 || ^9 +core_version_requirement: ^8 || ^9 diff --git a/core/modules/system/tests/themes/test_invalid_core_semver/test_invalid_core_semver.info.yml b/core/modules/system/tests/themes/test_invalid_core_semver/test_invalid_core_semver.info.yml index 28300f9c4c..a1e1c5a827 100644 --- a/core/modules/system/tests/themes/test_invalid_core_semver/test_invalid_core_semver.info.yml +++ b/core/modules/system/tests/themes/test_invalid_core_semver/test_invalid_core_semver.info.yml @@ -2,4 +2,4 @@ name: 'Theme test with invalid semver core version' type: theme description: 'Test theme which has an invalid semver core version.' version: VERSION -core_dependency: ^7 +core_version_requirement: ^7 diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php index e874cfb53e..f7f78bc575 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php @@ -103,93 +103,93 @@ public function testInfoParserMissingKeys() { } /** - * Tests that missing 'core' and 'core_dependency' keys are detected. + * Tests that missing 'core' and 'core_version_requirement' keys are detected. * * @covers ::parse */ - public function testMissingCoreCoreDependency() { - $missing_core_and_core_dependency = << [ - 'missing_core_and_core_dependency.info.txt' => $missing_core_and_core_dependency, + 'missing_core_and_core_version_requirement.info.txt' => $missing_core_and_core_version_requirement, ], ]); - $filename = vfsStream::url('modules/fixtures/missing_core_and_core_dependency.info.txt'); + $filename = vfsStream::url('modules/fixtures/missing_core_and_core_version_requirement.info.txt'); $this->expectException('\Drupal\Core\Extension\InfoParserException'); - $this->expectExceptionMessage("The 'core' or the 'core_dependency' key must be present in vfs://modules/fixtures/missing_core_and_core_dependency.info.txt"); + $this->expectExceptionMessage("The 'core' or the 'core_version_requirement' key must be present in vfs://modules/fixtures/missing_core_and_core_version_requirement.info.txt"); $this->infoParser->parse($filename); } /** - * Tests that 'core_dependency: ^8.8' is valid with no 'core' key. + * Tests that 'core_version_requirement: ^8.8' is valid with no 'core' key. * * @covers ::parse */ - public function testCoreDependency88() { - $core_dependency = << [ - 'core_dependency.info.txt' => $core_dependency, + 'core_version_requirement.info.txt' => $core_version_requirement, ], ]); - $filename = vfsStream::url('modules/fixtures/core_dependency.info.txt'); + $filename = vfsStream::url('modules/fixtures/core_version_requirement.info.txt'); $info_values = $this->infoParser->parse($filename); - $this->assertSame($info_values['core_dependency'], '^8.8'); + $this->assertSame($info_values['core_version_requirement'], '^8.8'); } /** - * Tests that 'core_dependency: ^8.8' is invalid with a 'core' key. + * Tests that 'core_version_requirement: ^8.8' is invalid with a 'core' key. * * @covers ::parse */ - public function testCoreCoreDependency88() { - $core_and_core_dependency_88 = << [ - 'core_and_core_dependency_88.info.txt' => $core_and_core_dependency_88, + 'core_and_core_version_requirement_88.info.txt' => $core_and_core_version_requirement_88, ], ]); - $filename = vfsStream::url('modules/fixtures/core_and_core_dependency_88.info.txt'); + $filename = vfsStream::url('modules/fixtures/core_and_core_version_requirement_88.info.txt'); $this->expectException('\Drupal\Core\Extension\InfoParserException'); - $this->expectExceptionMessage("The 'core_dependency' constraint (^8.8) requires the 'core' not be set in vfs://modules/fixtures/core_and_core_dependency_88.info.txt"); + $this->expectExceptionMessage("The 'core_version_requirement' constraint (^8.8) requires the 'core' not be set in vfs://modules/fixtures/core_and_core_version_requirement_88.info.txt"); $this->infoParser->parse($filename); } /** - * Tests that 'core_dependency: ^8.8' is invalid with a 'core' key. + * Tests a invalid 'core' key. * * @covers ::parse */ @@ -220,41 +220,41 @@ public function testInvalidCore() { } /** - * Tests that 'core_dependency' throws an exception if constraint is invalid. + * Tests a invalid 'core_version_requirement'. * * @covers ::parse * - * @dataProvider providerCoreDependencyInvalid + * @dataProvider providerCoreVersionRequirementInvalid */ - public function testCoreDependencyInvalid($file_name, $constraint) { - $invalid_core_dependency = << [ - "$file_name.info.txt" => $invalid_core_dependency, + "$file_name.info.txt" => $invalid_core_version_requirement, ], ]); $filename = vfsStream::url("modules/fixtures/$file_name.info.txt"); $this->expectException('\Drupal\Core\Extension\InfoParserException'); - $this->expectExceptionMessage("The 'core_dependency' can not be used to specify compatibility specific version before 8.7.7 in vfs://modules/fixtures/$file_name.info.txt"); + $this->expectExceptionMessage("The 'core_version_requirement' can not be used to specify compatibility specific version before 8.7.7 in vfs://modules/fixtures/$file_name.info.txt"); $this->infoParser->parse($filename); } /** - * Dataprovider for testCoreDependencyInvalid(). + * Dataprovider for testCoreVersionRequirementInvalid(). */ - public function providerCoreDependencyInvalid() { + public function providerCoreVersionRequirementInvalid() { return [ '8.0.0-alpha2' => ['alpha2', '8.0.0-alpha2'], '8.6.0-rc1' => ['rc1', '8.6.0-rc1'], @@ -318,6 +318,9 @@ public function testInfoParserCommonInfo() { $this->assertEquals($info_values['simple_string'], 'A simple string', 'Simple string value was parsed correctly.'); $this->assertEquals($info_values['version'], \Drupal::VERSION, 'Constant value was parsed correctly.'); $this->assertEquals($info_values['double_colon'], 'dummyClassName::method', 'Value containing double-colon was parsed correctly.'); + $this->assertSame('8.x', $info_values['core']); + $this->assertFalse(isset($info_values['core_version_requirement'])); + $this->assertFalse($info_values['core_incompatible']); } /** @@ -329,7 +332,7 @@ public function testCoreIncompatibility($file_name, $constraint, $expected) { $file_name = "core_incompatible_$file_name"; $core_incompatibility = <<