Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Feature Request: Uninstall hooks for Modules
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

My modules often add in special attributes that use source models and if you simply delete the add-on module without removing the attributes, your site stops working.

It can’t be that hard to implement the possibility to create “uninstall” scripts, like the setup scripts for installations.

Thanks,

Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

I have the same problem and second the vote for an uninstall capability for modules.  Just taking the current concept of the install script and class and implementing an uninstall script and class would be perfect.  couple that with the option to uninstall the module within the Admin UI and it would be a big improvment. 

Currently, if someone makes a module that adds an attribute that depends on a class in the module and you install it via Magento Connect, you cannot ‘uninstall’ it without hand editing the DB to remove the offending attribute.  This is easy enough for myself, but 90%+ of the Magento target audience has no clue how to fix a problem like this.

Please help us overcome this issue. 

I am willing to provide help, with guidance from the Varien developers.

 
Magento Community Magento Community
Magento Community
Magento Community
 
centerax
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-09-10
Montevideo, Uruguay
 

Any news on this?

I have the same problem and need to set a hook on my module uninstallation.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

Nothing new afaik…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amit Gupta
Jr. Member
 
Total Posts:  1
Joined:  2009-11-20
 

This is something really required

 
Magento Community Magento Community
Magento Community
Magento Community
 
steward
Member
 
Total Posts:  35
Joined:  2009-06-03
 
vinai-kung - 03 November 2008 05:22 AM

It can’t be that hard to implement

So implement it.

vinai-kung - 16 June 2009 10:20 PM

Nothing new afaik…

Looks like maybe you want to re-think “it’s not hard” ?

Here is how I deleted a payment gateway called something from a supplier called Vendor.

DELETE FROM `core_config_dataWHERE path LIKE 'payment/something%';
DELETE FROM `core_config_dataWHERE path LIKE '&#xVe;ndor_Something%';
DELETE FROM `core_resourceWHERE `code`='something_setup';
DELETE FROM `eav_attributeWHERE attribute_code LIKE 'something%';
DROP TABLE IF EXISTS `something_audit_log`;

I figured out what to delete by dumping the database and doing a search.
(Dump before and after the install, then compare to se what got added).
Also by poking around in the XML and mysql4-install-0.1.0.php files.

Other modules will present other challenges.

Low tech solution:
Always do a test install on a database you can afford to blow away.
Then blow it away!

 
Magento Community Magento Community
Magento Community
Magento Community
 
naturalcrusader
Jr. Member
 
Total Posts:  16
Joined:  2010-08-12
 
steward - 31 May 2010 01:38 PM

vinai-kung - 03 November 2008 05:22 AM
It can’t be that hard to implement

So implement it.

vinai-kung - 16 June 2009 10:20 PM

Nothing new afaik…

Looks like maybe you want to re-think “it’s not hard” ?

Here is how I deleted a payment gateway called something from a supplier called Vendor.

DELETE FROM `core_config_dataWHERE path LIKE 'payment/something%';
DELETE FROM `core_config_dataWHERE path LIKE '&#xVe;ndor_Something%';
DELETE FROM `core_resourceWHERE `code`='something_setup';
DELETE FROM `eav_attributeWHERE attribute_code LIKE 'something%';
DROP TABLE IF EXISTS `something_audit_log`;

I figured out what to delete by dumping the database and doing a search.
(Dump before and after the install, then compare to se what got added).
Also by poking around in the XML and mysql4-install-0.1.0.php files.

Other modules will present other challenges.

Low tech solution:
Always do a test install on a database you can afford to blow away.
Then blow it away!

tried all that.  deleted the files, deleted the cron job, deleted what i could find in the database, dumped it like you said.  but i am still getting the

Fatal error: Class ‘Camiloo_Amazonimport_Helper_Data’ not found in /public_html/app/Mage.php on line 520

any ideas on how to fix?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sander
Sr. Member
 
Avatar
Total Posts:  232
Joined:  2008-01-08
Netherlands
 

Uninstall possibilities would be highly useful!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shaun Pilkington
Jr. Member
 
Total Posts:  1
Joined:  2010-08-30
 

I just had this issue, or one very like it, when I wanted to reinstall a module that I was developing (that uses a custom table) manually (don’t ask). I ended up doing a global search in my DB for the module name.

I found something in core_resource and when I removed this, the module could be reinstalled itself correctly via the mysql4-install-0.1.0.php.

Hope this helps someone.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kalenjordan
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2011-10-31
Pasadena, CA
 

They got anything for this yet?  Did some quick googling for \"magento module uninstall\” and not seeing anything coming up at the moment.  Is everyone rolling their own....?

 
Magento Community Magento Community
Magento Community
Magento Community
 
raulsanchez
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2011-02-22
 

Same problem here… and a great problem, as a developer of extensions which uses eav attributes
After browsing lot of files under /downloader folder I think I’ve reach a solution… although I’ve no time right now to test it (I’ll do it tomorrow)

Maybe extending _uninstallResourceDb() or _modifyResourceDb() methods at Mage_Core_Model_Resource_Setup in order to add an event to get some info of the module being processed would be the way to control and perform the right uninstall operations of our modules?

 
Magento Community Magento Community
Magento Community
Magento Community
 
kalenjordan
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2011-10-31
Pasadena, CA
 

Thanks Raul!  You definitely sound like you’re on the right track.  I’ve got a couple other things on deck but I’m wanting to look into this pretty soon.  Could make a great community mod to abstract it out a bit so that mod devs could reuse it.

FYI I posted on stackoverflow as well - they didn’t really give me any pointers yet as far as where the best hooks are, but they did confirm that it’s not currently available in the core.

 
Magento Community Magento Community
Magento Community
Magento Community
 
raulsanchez
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2011-02-22
 

Update…

I have verified that, if $_callAfterApplyAllUpdates at Mage_Core_Model_Resource_Setup is set to TRUE, then afterApplyAllUpdates() is called after the update (install, reinstall or uninstall) process

So, a Model rewrite such as…

class Company_Module_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
    
    
/**
     * return TRUE, don't care about $_callAfterApplyAllUpdates, set to false by default
     */
    
public function getCallAfterApplyAllUpdates()
    
{
        
return TRUE;
    
}

    
public function afterApplyAllUpdates()
    
{
    
/* PERFORM SOME CODE HERE */
        
return $this;
    
}
}

... would allow us to perform the uninstall required code at /* PERFORM SOME CODE HERE */
Problem now is… how to set the overwrite for a Mage_Core_Model_* class in our config.xml?

I have tried it the usual ways with no success… any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
cyberlab
Member
 
Avatar
Total Posts:  51
Joined:  2011-12-29
Brazil - Curitiba - PR
 

I think the workaround now is create an uninstall option in the module config admin system configuration.;
before uninstall using the magento connect or before deleting all files from your FTP.

 
Magento Community Magento Community
Magento Community
Magento Community
 
raulsanchez
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2011-02-22
 
raulsanchez - 04 January 2012 02:19 AM

Update…

I have verified that, if $_callAfterApplyAllUpdates at Mage_Core_Model_Resource_Setup is set to TRUE, then afterApplyAllUpdates() is called after the update (install, reinstall or uninstall) process

So, a Model rewrite such as…

class Company_Module_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
    
    
/**
     * return TRUE, don't care about $_callAfterApplyAllUpdates, set to false by default
     */
    
public function getCallAfterApplyAllUpdates()
    
{
        
return TRUE;
    
}

    
public function afterApplyAllUpdates()
    
{
    
/* PERFORM SOME CODE HERE */
        
return $this;
    
}
}

… would allow us to perform the uninstall required code at /* PERFORM SOME CODE HERE */
Problem now is… how to set the overwrite for a Mage_Core_Model_* class in our config.xml?

I have tried it the usual ways with no success… any ideas?

Thinking it better…
This would never work… cause at this point, module files should be deleted from filesystem, so the rewrite should be deleted too

Another solution I’ve tried with no success…

/**
     * Uninstall resource
     *
     * @param string $version existing resource version
     * @return Mage_Core_Model_Resource_Setup
     */
    protected function _uninstallResourceDb($version)
    
{
        Mage
::dispatchEvent('module_uninstall', array('resource' => $this->_resourceName));
        
        
$this->_modifyResourceDb(self::TYPE_DB_UNINSTALL$version'');
        return 
$this;
    
}

Cause at this point I think the files still exists in filesystem
And then catching this event with Observer in my module, but…
Mage::dispatchEvent() doesn’t seem to work here… ¿?

 
Magento Community Magento Community
Magento Community
Magento Community
 
cyberlab
Member
 
Avatar
Total Posts:  51
Joined:  2011-12-29
Brazil - Curitiba - PR
 

I have resolved this by my especial module that I install together with all modules that i sell;

for example:

module custom price;
another module; come with
module cyberlab_plataform; -->for Now this activate deactivate all modules made by my company; now I am adding the option to uninstall;
them I need store the uninstall procedures in an file called uninstall.xml at moudule config dir;
this the idea… any another way?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2