Skip to content

Commit

Permalink
Fix #6025. drush pmu throws array to string conversion warning (#6036)
Browse files Browse the repository at this point in the history
* Fix #6025. drush pmu throws array to string conversion warning

* phpstan
  • Loading branch information
weitzman authored Jun 17, 2024
1 parent 0462184 commit e6d1bb4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Commands/pm/PmCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,16 @@ public function uninstall(array $modules): void
#[CLI\Hook(type: HookManager::ARGUMENT_VALIDATOR, target: PmCommands::UNINSTALL)]
public function validateUninstall(CommandData $commandData): void
{
$list = [];
if ($modules = $commandData->input()->getArgument('modules')) {
$modules = StringUtils::csvToArray($modules);
if ($validation_reasons = $this->getModuleInstaller()->validateUninstall($modules)) {
foreach ($validation_reasons as $module => $reason) {
$reasons[$module] = "$module: " . $reason;
foreach ($validation_reasons as $module => $reasons) {
foreach ($reasons as $reason) {
$list[] = "$module: " . (string)$reason;
}
}
throw new \Exception(implode("/n", $reasons));
throw new \Exception(implode("/n", $list));
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/functional/PmInUnListInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,10 @@ public function testEnDisUnList()
$this->drush(PmCommands::UNINSTALL, ['drush_empty_module'], [], null, null, self::EXIT_ERROR);
$out = $this->getErrorOutput();
$this->assertStringContainsString('The following module(s) are not installed', $out);

// Test uninstall of required module, and reason printing
$this->drush(PmCommands::UNINSTALL, ['user'], [], null, null, self::EXIT_ERROR);
$out = $this->getErrorOutput();
$this->assertStringContainsString('is required', $out);
}
}

0 comments on commit e6d1bb4

Please sign in to comment.