drush pm-uninstall doesn't seem to do dependencies "right" for Drupal 7, or certainly not in the same way as the modules page at admin/modules.
If you use the modules page, you're forced to go through an incredibly painful routine of uninstalling prerequisites and then uninstalling the module at hand. If you use drush uninstall though, it happily uninstalls whatever module you ask, even though this results in a PHP fatal the next thing you do, because some other module needs code from it to uninstall it.
A super-simple way to demonstrate: Install commerce, including commerce_tax and commerce_tax_ui (which depends on commerce_tax). Disable those two. Uninstall commerce_tax. Then uninstall commerce_tax_ui. You get a fatal.
rfay@rfay-bigsony:~/workspace/d7git$ drush uninstall commerce_tax
The following modules will be uninstalled: commerce_tax
Do you really want to continue? (y/n): y
commerce_tax was successfully uninstalled. [ok]
rfay@rfay-bigsony:~/workspace/d7git$ drush uninstall -y commerce_tax_ui
The following modules will be uninstalled: commerce_tax_ui
Do you really want to continue? (y/n): y
PHP Fatal error: Call to undefined function commerce_tax_rates() in /home/rfay/workspace/d7git/sites/all/modules/commerce/modules/tax/commerce_tax_ui.module on line 39
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Call to undefined function commerce_tax_rates() in
/home/rfay/workspace/d7git/sites/all/modules/commerce/modules/tax/commerce_tax_ui.module,
line 39
Actually, I'm a bit baffled that commerce_tax_rates() is called in the uninstall for commerce_tax_ui, since there is no hook_uninstall() implemented there.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | drush-1119686.patch | 928 bytes | jonhattan |
| #5 | rfay_dell_gazelle_Selection_016.png | 26.66 KB | rfay |
| #5 | rfay_dell_gazelle_Selection_017.png | 24.96 KB | rfay |
Comments
Comment #1
rfaycommerce_tax_rates() seems to be called in the uninstall of commerce_tax_ui() because it's used in hook_menu().
Comment #2
moshe weitzman commentedLooks like Drupal 7 introduced http://api.drupal.org/api/drupal/includes--install.inc/function/drupal_u... which does the dependency thing properly. IMO we should definitely fix this for D7. Fixes for prior versions are welcome as well.
Comment #3
jonhattanComment #4
moshe weitzman commentedLooks to me like drush already calls D7's drupal_uninstall_modules(). Not sure what I was thinking in #2. Perhaps this is a non issue, since a recent Drupal core commit fixed that hook_menu issue. Perhaps rfay can say if this is still a problem or not.
Comment #5
rfayI am not completely sure it's wrong, but certainly drush's behavior is different from the web UI.
Here's what I see with the web UI:
However, if I use drush it will happily uninstall commerce_tax:
Comment #6
jonhattanAttached a simple solution to make it behave as drupal does.
Comment #7
moshe weitzman commentedlooks good.
Comment #8
jonhattanCommited this fix for legacy compatibility.
--
I did think of a more drushic solution that may be implemented in a future: to proceed the same as pm-disable: disable all extensions depending on the one to be disabled. For pm-uninstall: uninstall all extensions depending on the one to be uninstalled if they're already disabled. Also a --force flag could disable & uninstall.
For example a utility of this is to quickly wipe completely the commerce suite.
Comment #9
jonhattanComment #10
msonnabaum commentedBackported.
Comment #12
Macronomicus commented#8 Is what used to happen ... whatever module and all its dependents were uninstalled in one nice quick command...
now pm-uninstall has lost its teeth and instead returns...
Why the switch?