diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index 64db0a8ed9..541b6a086c 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -121,15 +121,12 @@ public function parse($filename) { $parsed_info['dependencies'] = []; } // Module dependencies declared by themes should be in machine name - // format. The ability to specify version constraints or parse project - // prefixes will be available when it becomes possible for composer.json - // to support dependency metadata. - // - // @see https://www.drupal.org/project/drupal/issues/3005229 + // format. Module dependencies declared by a theme do not support version + // constraints or project prefixes. if ($parsed_info['type'] === 'theme' && isset($parsed_info['dependencies'])) { $non_machine_name_dependencies = preg_grep('/[^a-z0-9_]+/', $parsed_info['dependencies']); if (!empty($non_machine_name_dependencies)) { - throw new InfoParserException("Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by {$parsed_info['name']} is not in machine name format: " . implode(',', $non_machine_name_dependencies)); + throw new InfoParserException("Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by $filename is not in machine name format: " . implode(',', $non_machine_name_dependencies)); } } } diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php index c0ada9e028..8196735c4f 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php @@ -548,12 +548,12 @@ public function testUnparsableThemeModuleDependency($theme_yml, $exception_messa vfsStream::setup('modules'); vfsStream::create([ 'fixtures' => [ - 'unparsable_module_dependency.info.txt' => $theme_yml, + 'unparsable_module_dependency.info.yml' => $theme_yml, ], ]); $this->expectException(InfoParserException::class); $this->expectExceptionMessage($exception_message); - $this->infoParser->parse(vfsStream::url('modules/fixtures/unparsable_module_dependency.info.txt')); + $this->infoParser->parse(vfsStream::url('modules/fixtures/unparsable_module_dependency.info.yml')); } /** @@ -572,7 +572,6 @@ public function providerTestUnparsableThemeModuleDependency() { UNPARSABLE; $has_project_prefix = << [ $has_version_constraints, - 'Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by Test Theme Depending on Modules is not in machine name format: module_with_some_version_metadata (>4.1)', + 'Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by vfs://modules/fixtures/unparsable_module_dependency.info.yml is not in machine name format: module_with_some_version_metadata (>4.1)', ], 'has_project_prefix' => [ $has_project_prefix, - 'Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by Test Theme Depending on Modules is not in machine name format: drupal::module_with_a_project_prefix', + 'Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by vfs://modules/fixtures/unparsable_module_dependency.info.yml is not in machine name format: drupal::module_with_a_project_prefix', ], 'has_a_space' => [ $has_a_space, - 'Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by Test Theme Depending on Modules is not in machine name format: apparently_i_have_a space', + 'Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by vfs://modules/fixtures/unparsable_module_dependency.info.yml is not in machine name format: apparently_i_have_a space', ], 'has_capital' => [ $has_capital, - 'Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by Test Theme Depending on Modules is not in machine name format: capitalLetters', + 'Theme module dependencies must be machine names (only underscores, digits, and lowercase letters). At least one dependency declared by vfs://modules/fixtures/unparsable_module_dependency.info.yml is not in machine name format: capitalLetters', ], ]; }