diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index b255c02a01..8868f296e6 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -79,11 +79,19 @@ public function parse($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_version_requirement_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 for a specific version before " . static::FIRST_CORE_VERSION_REQUIREMENT_SUPPORTED_VERSION . " in $filename"); + // 'core_version_requirement' key. + if ($supports_pre_core_version_requirement_version) { + // 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 (!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 for a specific version before " . static::FIRST_CORE_VERSION_REQUIREMENT_SUPPORTED_VERSION . " in $filename"); + } + else { + if (!isset($parsed_info['core'])) { + throw new InfoParserException("If the 'core_version_requirement' specifies compatibility with all versions of Drupal 8 like '^8' the 'core: 8.x' must also be set in $filename"); + } + } + } } 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 47eec87f48..e3501a5f0b 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_version_requirement: ^8 +core_version_requirement: ^8.7.7 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 74e908530d..86bdbd3471 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_version_requirement: ^8 +core_version_requirement: ^8.7.7 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 4645badc2a..d58c91bd65 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_version_requirement: ^8 || ^9 +core_version_requirement: ^8.7.7 || ^9 diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php index 1af2972383..a15d01b330 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php @@ -381,7 +381,7 @@ public function testInfoParserCommonInfo() { * * @dataProvider providerCoreIncompatibility */ - public function testCoreIncompatibility($test_case, $constraint, $expected) { + public function testCoreIncompatibility($test_case, $constraint, $include_core, $expected) { $core_incompatibility = << [ 'next_minor', "^$major.$next_minor", + FALSE, TRUE, ], 'current_major_next_major' => [ 'current_major_next_major', "^$major || ^$next_major", + TRUE, FALSE, ], 'previous_major_next_major' => [ 'previous_major_next_major', "^1 || ^$next_major", + FALSE, TRUE, ], 'invalid' => [ 'invalid', 'this-string-is-invalid', + FALSE, TRUE, ], 'current_minor' => [ 'current_minor', "~$major.$minor", FALSE, + FALSE, ], ]; }