Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drush en incorrectly reports that it enabled new dependency modules #5057

Open
wants to merge 3 commits into
base: 11.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Drupal/Commands/pm/PmCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ public function install(array $modules): void
$this->output()->writeln(dt('The following module(s) will be enabled: !list', $todo_str));
return;
} elseif (array_values($todo) !== $modules) {
if(!in_array($modules, $todo_str)) {
$this->output()->writeln(dt('Requested module is already enabled: !list', ['!list' => implode(', ', $modules)]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be. a logger msg of severity=notice

foreach($todo_str as $todo_module) {
$this->enable([$todo_module]);
}
}
$this->output()->writeln(dt('The following module(s) will be enabled: !list', $todo_str));
if (!$this->io()->confirm(dt('Do you want to continue?'))) {
throw new UserAbortException();
Expand Down
13 changes: 12 additions & 1 deletion tests/functional/PmInUnListInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Unish;

use Composer\Semver\Comparator;

use Drush\Drupal\Commands\pm\PmCommands;
/**
* @group slow
* @group pm
Expand Down Expand Up @@ -46,6 +46,17 @@ public function testEnDisUnList()
$this->drush('core:status', [], ['field' => 'drupal-version']);
$drupal_version = $this->getOutputRaw();

// Test pm-enable enables a dependent module for already enabled module,
// and pm-list verifies that.
$list_of_dependent_modules = PmCommands::addInstallDependencies('drush_empty_module');
$dependent_modules = ['!list' => implode(', ', $list_of_dependent_modules)];
foreach($dependent_modules as $dependent_module){
$this->drush('pm-enable', [$dependent_module]);
$this->drush('pm-list', [], ['status' => 'enabled']);
$out = $this->getOutput();
$this->assertStringContainsString($module_dependency, $out);
}

// Test the testing install profile theme is installed.
$active_theme = 'stark';
$this->assertStringContainsString($active_theme, $out, 'Themes are in the pm-list');
Expand Down