diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index d54304cfc9..7257c48f4d 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -57,6 +57,11 @@ public function parse($filename) { if (!empty($missing_keys)) { throw new InfoParserException('Missing required keys (' . implode(', ', $missing_keys) . ') in ' . $filename); } + if ($parsed_info['type'] === 'profile' && isset($parsed_info['core_version_requirement'])) { + // @todo Support the 'core_version_requirement' key in profiles in + // https://www.drupal.org/node/3070401. + throw new InfoParserException("The 'core_version_requirement' key is not supported in profiles 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); } diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php index 471d18e93f..45e2b975b4 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php @@ -442,4 +442,27 @@ public function providerCoreIncompatibility() { ]; } + /** + * Test a profile info file with the 'core_version_requirement' key. + */ + public function testInvalidProfile() { + $profile = << [ + 'invalid_profile.info.txt' => $profile, + ], + ]); + $this->expectException('\Drupal\Core\Extension\InfoParserException'); + $this->expectExceptionMessage("The 'core_version_requirement' key is not supported in profiles in vfs://profiles/fixtures/invalid_profile.info.txt"); + $this->infoParser->parse(vfsStream::url('profiles/fixtures/invalid_profile.info.txt')); + } + }