Do not assume that Composer package names will exactly match Drupal projects names

Created on 16 August 2022, over 2 years ago
Updated 19 April 2024, 7 months ago

Problem/Motivation

Right now in multi places we are assuming that for a give Composer package that corresponds to Drupal project if the package name is drupal/my_package the Drupal project name will be my_package
If for a given Drupal project named my_project the composer package name will be drupal/my_project

This is usually true but not always so we should not assume so.

In #3296261: Add the ability to map package names to project names and vice-versa we added \Drupal\package_manager\ComposerUtility::getPackageForProject() and \Drupal\package_manager\ComposerUtility::getProjectForPackage

These 2 public methods will allow us to do a real conversion.

Proposed resolution

Updated all the places we are making these assumptions to use the new methods.

not sure if this is complete list but from

Here is what I think is affected and not affected by this

In automatic_updates

  1. \Drupal\automatic_updates\Validator\StagedProjectsValidator is ok because we just don't allow any updates to any non-core projects
  2. \Drupal\automatic_updates\Validator\VersionPolicyValidator is ok because hopefully drupal/core will never change

In automatic_updates_extensions we need some central way of given a drupal project name getting a composer namespace based on the current code.

  1. \Drupal\automatic_updates_extensions\Form\UpdateReady::getProjectTitle
  2. \Drupal\automatic_updates_extensions\Form\UpdaterForm::getRecommendedModuleUpdates will need to do the conversion

Fixed in other issues

  1. #3296275: UpdateReleaseValidator should not assume composer namespace matches drupal project name
  2. once ExtensionUpdater::begin() is fixed then it will have the valid namespaces. In pre-apply it is looking for any drupal projects that weren't in the active composer. So it doesn't matter if project names and composer names match
  3. The existing issue #3293427-5: Display all projects that will be updated in Extensions confirmation form will need to do the conversion

Testing

The tests in the Old MR are obsolete now so the main problem described in the issue was the assumptions about how the project name and package name were related and with the new methods introduced in 📌 Add new InstalledPackagesList which does not rely on Composer API to get package info Fixed (\Drupal\package_manager\InstalledPackagesList::getPackageByDrupalProjectName and \Drupal\package_manager\InstalledPackage::getProjectName) it's no more the case and it has it's own coverage in \Drupal\Tests\package_manager\Kernel\InstalledPackagesListTest so i don't think more testing is required.

Remaining tasks

🐛 Bug report
Status

Fixed

Version

3.0

Component

Automatic Updates Extensions

Created by

🇺🇸United States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024