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.

Comments

rfay’s picture

commerce_tax_rates() seems to be called in the uninstall of commerce_tax_ui() because it's used in hook_menu().

moshe weitzman’s picture

Looks 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.

jonhattan’s picture

Assigned: Unassigned » jonhattan
moshe weitzman’s picture

Status: Active » Postponed (maintainer needs more info)

Looks 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.

rfay’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new24.96 KB
new26.66 KB

I 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:

rfay_dell_gazelle_Selection_016.png

However, if I use drush it will happily uninstall commerce_tax:

rfay_dell_gazelle_Selection_017.png

jonhattan’s picture

Status: Active » Needs review
StatusFileSize
new928 bytes

Attached a simple solution to make it behave as drupal does.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

looks good.

jonhattan’s picture

Status: Reviewed & tested by the community » Fixed

Commited 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.

jonhattan’s picture

Version: » All-versions-4.x-dev
Assigned: jonhattan » msonnabaum
Status: Fixed » Patch (to be ported)
msonnabaum’s picture

Status: Patch (to be ported) » Fixed

Backported.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Macronomicus’s picture

#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...

...
offending_module is a required module and can't be disabled.                                        [ok]
There were no extensions that could be disabled.                                                     [ok]

Why the switch?