deactivate_plugins called within a deactivation callback doesn't work
|Reported by:||stephenh1988||Owned by:|
This problem occurs when you attempt to deactivate another a plug-in, when some other plug-in is deactivated. For instance, you may want to deactivate all 'dependent' plug-ins when their 'parent' plug-in is deactivated.
First deactivate_plugins (Link to source: https://github.com/WordPress/WordPress/blob/3.4.1/wp-admin/includes/plugin.php#L580) retrieves an array of active plug-ins, and removes the plugin to be deactivated. It then triggers the plug-in's deactivation hook (inside which someone may try to deactivate a second plug-in). Once the actions have been completed, the array of active plug-ins is updated to the database - but this array does not reflect any activation / deactivation that has taken place as a result of the triggered actions.
Consequently the array is updated with only the original plug-in removed.
Importantly, the deactivation callbacks for all plug-ins are triggered, but all but the original plug-in exist as active in the database.