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

Adds unit test.

Props jbrinley.
Fixes #28651.


git-svn-id: https://develop.svn.wordpress.org/trunk@29818 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-10-02 15:55:51 +00:00
parent 46b4ea2a6c
commit dcef5d4583
2 changed files with 24 additions and 1 deletions

View File

@@ -301,6 +301,29 @@ class Tests_MS extends WP_UnitTestCase {
$this->assertEquals( 1, $this->plugin_hook_count ); // testing actions and silent mode
}
/**
* @ticket 28651
*/
function test_duplicate_network_active_plugin() {
$path = "hello.php";
$mock = new MockAction();
add_action( 'activate_' . $path, array ( $mock, 'action' ) );
// should activate on the first try
activate_plugin( $path, '', true );
$active_plugins = wp_get_active_network_plugins();
$this->assertCount( 1, $active_plugins );
$this->assertEquals( 1, $mock->get_call_count() );
// should do nothing on the second try
activate_plugin( $path, '', true );
$active_plugins = wp_get_active_network_plugins();
$this->assertCount( 1, $active_plugins );
$this->assertEquals( 1, $mock->get_call_count() );
remove_action( 'activate_' . $path, array ( $mock, 'action' ) );
}
function _helper_deactivate_hook() {
$this->plugin_hook_count++;
}