Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#21122 closed defect (bug) (duplicate)

deactivate_plugins called within a deactivation callback doesn't work

Reported by: stephenh1988 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Plugins Keywords:
Focuses: Cc:


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.

Change History (3)

#1 @nacin
9 years ago

This is a duplicate as another ticket.

As a workaround, hook into shutdown and deactivate then.

#2 @stephenh1988
9 years ago

Thanks Andrew - sorry for the duplication, do you have a link to the ticket, I couldn't find it? I have a patch ready for this, if the other ticket doesn't have one yet.

#3 @nacin
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.