What should a well-behaved package do for uninstall cleanup?
Permalink 1 user found helpful
I'm finishing up a theme which has a few simple blocks included. I know there is an uninstall method I can put into my package controller, but I'm wondering if it is necessary to cleanup db tables for the blocks. I checked around 10 packages on my system and so far, only one has an uninstall() implemented. Does the c5 core itself cleanup when a package is uninstalled or do I need to take care of removing db tables for my blocks that are included in the package? What should a well-behaved package do?
Thanks,
Donna
Thanks,
Donna
If you pass the package variable that gets created in the install() method to your blocks when you create them (which you will have to do, or concrete5 won't be able to find them) then they should be uninstalled automatically if the package is uninstalled. A good way to test this is to install the package, then go to uninstall it. concrete5 should list all the items that are associated with this package, and will automatically remove them when the package is uninstalled.
Now, we don't automatically remove database tables in this process, so you could potentially override the uninstall method and drop the tables manually, but I don't really believe its necessary. In the core, in the future, we might actually do this, but right now we're not.