Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#28651 closed defect (bug) (fixed)

activate_plugin() re-triggers activation routine for already-active network plugins

Reported by: jbrinley's profile jbrinley Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.8
Component: Plugins Keywords: has-patch
Focuses: multisite Cc:

Description

In activate_plugins(), there's a check to see if the plugin you are activating is already in the array of currently active plugins. If that fails, nothing else should happen in activate_plugins(); it just skips to the end and returns null.

When network activating a plugin, though, the $current array is flipped. Plugin paths are keys, and the values are activation timestamps. The in_array() will always return false, unless one of the plugins happens to have a timestamp of 0. So if a plugin is already network active, sending it through activate_plugin() again will trigger 'activate_plugin' and 'activate_' . $plugin again on the already-active plugin.

Attachments (1)

28651.patch (1.9 KB) - added by jbrinley 9 years ago.
Checks for already active network plugins in the correct location

Download all attachments as: .zip

Change History (6)

@jbrinley
9 years ago

Checks for already active network plugins in the correct location

#1 @jbrinley
9 years ago

  • Keywords has-patch added

I ran into this when using an mu-plugin to force certain plugins to be active. Since my plugin was giving network-active plugins a timestamp of 0, it was preventing me from manually network activating plugins. Fairly trivial to work around in my plugin, but it did expose this minor bug.

The attached patch fixes the bug and adds a unit test for it.

#2 @nofearinc
9 years ago

I've encountered a similar issue earlier this year, cannot verify the patch but +1 for the bug report.

#3 @tellyworth
9 years ago

  • Version changed from trunk to 3.8

I was able to reproduce this in 3.9 and 3.8 with the unit test.

#4 @wonderboymusic
9 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 29818:

In activate_plugin(), do not re-run the activation routine for already-active network-wide plugins.

Adds unit test.

Props jbrinley.
Fixes #28651.

#5 @DrewAPicture
9 years ago

  • Milestone changed from Awaiting Review to 4.1
Note: See TracTickets for help on using tickets.