1
0
Fork 0

Add abandoned flag to show/outdated commands package lists (#10485)

To synchronize `abandoned` information with JSON APIs and the `composer.json` information of a package, we should return the following types: `bool|non-empty-string`.
This will either state if a package is abandoned and, if there is a replacement declared, what replacement package should be used instead.

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
pull/10488/head
Maximilian Bösing 2022-02-03 21:34:54 +01:00 committed by GitHub
parent 3ae111140f
commit 1704466b74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -461,8 +461,10 @@ EOT
$packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"); $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
} }
$packageIsAbandoned = false;
if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) { if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
$replacement = is_string($latestPackage->getReplacementPackage()) $replacementPackageName = $latestPackage->getReplacementPackage();
$replacement = $replacementPackageName !== null
? 'Use ' . $latestPackage->getReplacementPackage() . ' instead' ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
: 'No replacement was suggested'; : 'No replacement was suggested';
$packageWarning = sprintf( $packageWarning = sprintf(
@ -471,7 +473,10 @@ EOT
$replacement $replacement
); );
$packageViewData['warning'] = $packageWarning; $packageViewData['warning'] = $packageWarning;
$packageIsAbandoned = $replacementPackageName ?? true;
} }
$packageViewData['abandoned'] = $packageIsAbandoned;
} else { } else {
$packageViewData['name'] = $package; $packageViewData['name'] = $package;
$nameLength = max($nameLength, strlen($package)); $nameLength = max($nameLength, strlen($package));