Skip to content

Commit

Permalink
Fix #5651. drush sec could give better guidance when using drupal/cor…
Browse files Browse the repository at this point in the history
…e-recommended (#5684)
  • Loading branch information
weitzman authored Jul 3, 2023
1 parent 3285e33 commit 2dd7b48
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Commands/pm/SecurityUpdateCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function security(array $options = ['no-dev' => false]): RowsOfFields|Com
$composer_lock_data = $this->loadSiteComposerLock();
$updates = $this->calculateSecurityUpdates($composer_lock_data, $security_advisories_composer_json, $options['no-dev']);
if ($updates) {
$this->suggestComposerCommand($updates);
$this->suggestComposerCommand($updates, $composer_lock_data['packages']);
return CommandResult::dataWithExitCode(new RowsOfFields($updates), self::EXIT_FAILURE_WITH_CLARITY);
}
$this->logger()->success("<info>There are no outstanding security updates for Drupal projects.</info>");
Expand All @@ -70,10 +70,14 @@ public function security(array $options = ['no-dev' => false]): RowsOfFields|Com
/**
* Emit suggested Composer command for security updates.
*/
public function suggestComposerCommand($updates): void
public function suggestComposerCommand($updates, array $composer_lock_packages): void
{
$suggested_command = 'composer require ';
foreach ($updates as $package) {
// Improve guidance for 'recommended' users.
if ($package['name'] == 'drupal/core' && isset($composer_lock_packages['drupal/core-recommended'])) {
$package['name'] = 'drupal/core-recommended';
}
$suggested_command .= $package['name'] . ' ';
}
$suggested_command .= '--update-with-dependencies';
Expand Down

0 comments on commit 2dd7b48

Please sign in to comment.