Opened 10 years ago
Closed 9 years ago
#30673 closed enhancement (wontfix)
plugin uninstall.php not called when multisite site is deleted
Reported by: | dpik | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.0.1 |
Component: | Networks and Sites | Keywords: | |
Focuses: | multisite | Cc: |
Description
I have a multisite installation (4.0.1) with revolution slider plugin installed. This plugin has an uninstall.php file (that deletes revslider's database tables) which should be called on plugin removal (http://codex.wordpress.org/Function_Reference/register_uninstall_hook). It does not call the register_uninstall_hook function.
The problem is: when i delete a site from the network dashboard, revslider databases are kept, meaning that uninstall.php was not called. I'm not sure this issue can be addressed and i did not tried with a plugin using the register_uninstall_hook (which is the best method if i did understand the documentation correctly).
Questions: Can this problem be fixed ? Is the register_uninstall_hook called when deleting a site in multisite configuration ?
Change History (4)
#2
@
9 years ago
I propose the following code:
add_action( 'delete_blog', 'deactivate_blogs_plugins'); function deactivate_blogs_plugins() { $active_plugins = get_option('active_plugins'); foreach( $active_plugins as $key => $value) { $plugin_directory = explode('/',$value); // Folder name will be displayed deactivate_plugins( plugin_basename( $plugin_directory ), false, false ); } }
I tested this with Easy Digital Downloads which creates a wp_#_edd_comments
table. When I deactivate the plugin, the additional table is present. I don't think my code above will help correct this.
Any suggestions?
#3
@
9 years ago
I question if this should ever be implemented. Many plugins will be written to expect that it only happens on plugin removal and may potentially destroy their global tables.
If the plugin is active, it can catch the delete and remove the tables itself.
#4
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
Yeah, this is definitely something we cannot and should not change. If there's not a page somewhere already, it's worth documenting the oddities of activation/deactivation/uninstall hooks as they relate to multisite, and how to best deal with different situations.
Related: #14170, #28363