Skip to content

Commit

Permalink
Issue [1430426] by moshe weitzman and juampy: Bad error message - Com…
Browse files Browse the repository at this point in the history
…mand pm-updatecode needs the following module enabled to run: pm.

Added logic to consider 'drupal dependencies' array within the command metadata to find out modules which this command depends on.
  • Loading branch information
juampynr authored and weitzman committed Feb 9, 2012
1 parent 7bac5e9 commit 95bb76c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,16 @@ function drush_command_belongs_to_disabled_module(&$command) {
$command_name = array_shift(drush_get_arguments());
if (isset($commands[$command_name])) {
// We found it. Load its module name and set an error.
$command_files = drush_get_context('DRUSH_COMMAND_FILES', array());
$command_path = $commands[$command_name]['path'] . DIRECTORY_SEPARATOR . $commands[$command_name]['commandfile'] . '.drush.inc';
$module = array_search($command_path, $command_files);
if (is_array($commands[$command_name]['drupal dependencies']) && count($commands[$command_name]['drupal dependencies'])) {
$modules = implode(', ', $commands[$command_name]['drupal dependencies']);
} else {
// The command does not define Drupal dependencies. Derive them.
$command_files = drush_get_context('DRUSH_COMMAND_FILES', array());
$command_path = $commands[$command_name]['path'] . DIRECTORY_SEPARATOR . $commands[$command_name]['commandfile'] . '.drush.inc';
$modules = array_search($command_path, $command_files);
}
$command['bootstrap_errors']['DRUSH_COMMAND_DEPENDENCY_ERROR'] =
dt('Command !command needs the following module enabled to run: !dependency.', array('!command' => $command_name, '!dependency' => $module));
dt('Command !command needs the following module(s) enabled to run: !dependencies.', array('!command' => $command_name, '!dependencies' => $modules));
}
}
}

0 comments on commit 95bb76c

Please sign in to comment.