Make WordPress Core

Ticket #28651: 28651.patch

File 28651.patch, 1.9 KB (added by jbrinley, 9 years ago)

Checks for already active network plugins in the correct location

  • src/wp-admin/includes/plugin.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    533533        if ( is_wp_error($valid) )
    534534                return $valid;
    535535
    536         if ( !in_array($plugin, $current) ) {
     536        if ( ( $network_wide && !isset($current[$plugin]) ) || ( !$network_wide && !in_array($plugin, $current) ) ) {
    537537                if ( !empty($redirect) )
    538538                        wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
    539539                ob_start();
  • tests/phpunit/tests/ms.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    301301                $this->assertEquals( 1, $this->plugin_hook_count ); // testing actions and silent mode
    302302        }
    303303
     304        /**
     305         * @ticket 28651
     306         */
     307        function test_duplicate_network_active_plugin() {
     308                $path = "hello.php";
     309                $mock = new MockAction();
     310                add_action( 'activate_' . $path, array ( $mock, 'action' ) );
     311
     312                // should activate on the first try
     313                activate_plugin( $path, '', true );
     314                $active_plugins = wp_get_active_network_plugins();
     315                $this->assertCount( 1, $active_plugins );
     316                $this->assertEquals( 1, $mock->get_call_count() );
     317
     318                // should do nothing on the second try
     319                activate_plugin( $path, '', true );
     320                $active_plugins = wp_get_active_network_plugins();
     321                $this->assertCount( 1, $active_plugins );
     322                $this->assertEquals( 1, $mock->get_call_count() );
     323
     324                remove_action( 'activate_' . $path, array ( $mock, 'action' ) );
     325        }
     326
    304327        function _helper_deactivate_hook() {
    305328                $this->plugin_hook_count++;
    306329        }