Skip to content
Snippets Groups Projects

Issue #3304142: Do not assume that Composer package names will exactly match Drupal projects names

Files
10
@@ -7,6 +7,7 @@ namespace Drupal\automatic_updates_extensions\Form;
use Drupal\automatic_updates\Form\UpdateFormBase;
use Drupal\package_manager\ComposerInspector;
use Drupal\package_manager\Exception\StageFailureMarkerException;
use Drupal\package_manager\InstalledPackage;
use Drupal\package_manager\PathLocator;
use Drupal\package_manager\ProjectInfo;
use Drupal\package_manager\ValidationResult;
@@ -230,7 +231,7 @@ final class UpdateReady extends UpdateFormBase {
continue;
}
$updated_project_info[$name] = [
'title' => $this->getProjectTitle($updated_package->name),
'title' => $this->getProjectTitleFromPackage($updated_package),
'installed_version' => $installed_packages[$updated_package->name]->version,
'updated_version' => $updated_package->version,
];
@@ -262,21 +263,25 @@ final class UpdateReady extends UpdateFormBase {
/**
* Gets the human-readable project title for a Composer package.
*
* @param string $package_name
* Package name.
* @param \Drupal\package_manager\InstalledPackage $package
* The installed package.
*
* @return string
* The human-readable title of the project.
* The human-readable title of the project. If no project information is
* available, the package name is returned.
*/
private function getProjectTitle(string $package_name): string {
$project_name = str_replace('drupal/', '', $package_name);
private function getProjectTitleFromPackage(InstalledPackage $package): string {
$project_name = $package->getProjectName();
if (!$project_name) {
return $package->name;
}
$project_info = new ProjectInfo($project_name);
$project_data = $project_info->getProjectInfo();
if ($project_data) {
return $project_data['title'];
}
else {
return $project_name;
return $package->name;
}
}
Loading