Enable a module before drush updatedb runs.. via that module

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by hefox on September 16, 2010 at 5:05am

in mymodule.drush.inc

<?php
/**
* Implementation of drush_hook_pre_updatedb().
*/
function drush_mymodule_pre_updatedb() {
drush_bootstrap_max();
if (!
module_exists('mymodule')) {
module_enable(array('mymodule'));
}
}
?>

Comments

The takeaway is that Drush

Posted by Garrett Albright on September 16, 2010 at 5:42pm

The takeaway is that Drush calls the drush_hook_pre_updatedb() (and possibly other Drush hooks?) of disabled modules, which these modules can take advantage of to enable themselves.

I chatted with hefox about this on IRC. I personally am leaning toward this being a bug (or "unintended feature") in Drush, but hefox thinks it makes sense in terms of creating Drush-only modules...

This recently changed in

Posted by moshe weitzman on September 17, 2010 at 1:23pm

This recently changed in Drush HEAD. If your command does a BOOTSTRAP_FULL, only enabled modules can participate in drush_invoke() hooks like pre_updatedb. If the command bootstraps to a couple levels lower, drush commandfiles are indeed eligible to hook in. See http://drupal.org/node/861822#comment-3319040 and later comments.

In Drush 3, you are correct that commandfiles in disabled modules are in play for hooks for all drush commands.

Drupal for Evil

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /