Skip to content
Snippets Groups Projects
Commit 80cf7125 authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3305874 by tedbow, omkar.podey:...

Issue #3305874 by tedbow, omkar.podey: \Drupal\package_manager\ComposerUtility::getPackageForProject() assumes direct project to package conversion when it should not
parent d64c9f30
No related branches found
No related tags found
No related merge requests found
...@@ -255,12 +255,6 @@ class ComposerUtility { ...@@ -255,12 +255,6 @@ class ComposerUtility {
public function getPackageForProject(string $project_name): ?string { public function getPackageForProject(string $project_name): ?string {
$installed = $this->getInstalledPackagesData(); $installed = $this->getInstalledPackagesData();
// If we're lucky, the package name is the project name, prefixed with
// `drupal/`.
if (array_key_exists("drupal/$project_name", $installed)) {
return "drupal/$project_name";
}
$installed = array_keys($installed); $installed = array_keys($installed);
foreach ($installed as $package_name) { foreach ($installed as $package_name) {
if ($this->getProjectForPackage($package_name) === $project_name) { if ($this->getProjectForPackage($package_name) === $project_name) {
......
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
"version": "6.1.3", "version": "6.1.3",
"type": "drupal-theme" "type": "drupal-theme"
}, },
{
"name": "drupal/not_match_path_project",
"version": "6.1.3",
"type": "drupal-module"
},
{ {
"name": "non_drupal/other_project", "name": "non_drupal/other_project",
"version": "6.1.3", "version": "6.1.3",
......
...@@ -15,6 +15,10 @@ return [ ...@@ -15,6 +15,10 @@ return [
'type' => 'drupal-module', 'type' => 'drupal-module',
'install_path' => $projects_dir . '/not_match_project', 'install_path' => $projects_dir . '/not_match_project',
], ],
'drupal/not_match_path_project' => [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/not_match_project',
],
'drupal/nested_no_match_package' => [ 'drupal/nested_no_match_package' => [
'type' => 'drupal-module', 'type' => 'drupal-module',
'install_path' => $projects_dir . '/any_folder_name', 'install_path' => $projects_dir . '/any_folder_name',
......
...@@ -187,6 +187,10 @@ class ComposerUtilityTest extends KernelTestBase { ...@@ -187,6 +187,10 @@ class ComposerUtilityTest extends KernelTestBase {
'not_match_project', 'not_match_project',
'drupal/not_match_package', 'drupal/not_match_package',
], ],
'package and project match + wrong installed path' => [
'not_match_path_project',
NULL,
],
'vendor is not drupal' => [ 'vendor is not drupal' => [
'other_project', 'other_project',
NULL, NULL,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment