views:

61

answers:

6

After months using Drupal for my websites I noticed module uninstall tab in the modules list.

I've always uninstalled my modules by deleting their folders from filesystem (after disabling them). I was wondering if this is the wrong way to remove them.

Thanks

+1  A: 

The uninstall tab will remove anything in your database related to the module. This operation requires the module to still be present in your modules directory.

Simply deleting the files isn't 'wrong', but it will leave unneeded cruft in your database. The uninstall tab will not remove the module files for you, you need to do that yourself as you have been doing.

Matthew Scharley
+5  A: 

When you uninstall the module, rather then just disabling and removing, you let the module clean up after itself, including:

  • Delete tables it created
  • Delete system variables it used.

So uninstalling is a good clean, for the health of your database. Things will work fine not doing it, but why keep unused tables in your database?

Note:
It's up to the module creator to create the code needed to do the clean up, so not all modules do this very well.

googletorp
A: 

You can check this link - modules may have some additional uninstall instructions for them, but it looks like majority of them don't - that's why you didn't have any issues :)

NPC
+2  A: 

Uninstalling is sometimes needed, as hook_install() won't fire if a module is just disabled. So if for example a module has some corrupted data, disabling and re enabling won't remove that.

You will probably be ok in your approach. However one thing to be weary of is doing the following.

  1. Disable
  2. Remove folder
  3. At a later date put module back again (not the same version)
  4. Uninstalling.

The reason for this is hook_install() and hook_uninstall() should be mirror images of each other. Update hooks are used to keep a module schema and settings up to date with what is provided in hook_install(), if you were to use an updated module to uninstall (without updating) it will be trying to uninstall a different set up to what is expected. The risk is slim that something would go badly wrong, but it is worth being careful.

Jeremy French
+2  A: 

I've always uninstalled my modules by deleting their folders from filesystem (after disabling them). I was wondering if this is the wrong way to remove them.

The files used from a module is not the only thing a module leaves on a Drupal site; there are database tables, Drupal variables, cached values that still need to be removed, when uninstalling a module. It's also possible that a module adds rows into a database table created from a different module.
The bigger problem I see is that, deleting the module files, you are not removing any reference to the module contained in the table system. This means that if you are copying back the same module after you deleted it, and you did delete its tables, the module is not going to re-create the database tables it needs.

I would definitively say that that is the wrong way to uninstall a module.

kiamlaluno
+1  A: 

Drush makes the module uninstall process much more pleasant, with something like:

drush pm-disable [module]  // or its shorthand drush dis [module]
drush pm-uninstall [module]

In fact, Drush makes just about everything more pleasant (downloading/installing modules, dealing with install profiles, creating DB backups, and my personal favorite, updating your entire code base). If you're not already using it, I highly recommend giving it a try.

peterjmag

related questions