Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#28651 closed defect (bug) (fixed)

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

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

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 12 years ago.
Checks for already active network plugins in the correct location

Download all attachments as: .zip

Change History (6)

@jbrinley
12 years ago

Checks for already active network plugins in the correct location

#1 @jbrinley
12 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
12 years ago

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

#3 @tellyworth
12 years ago

  • Version trunk → 3.8

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

#4 @wonderboymusic
12 years ago

  • Owner set to wonderboymusic
  • Resolution → fixed
  • Status new → 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
12 years ago

  • Milestone Awaiting Review → 4.1
Note: See TracTickets for help on using tickets.