diff --git a/features/plugin.feature b/features/plugin.feature index 879f1e89..cacaa996 100644 --- a/features/plugin.feature +++ b/features/plugin.feature @@ -298,6 +298,44 @@ Feature: Manage WordPress plugins """ And the return code should be 0 + @require-wp-5.2 + Scenario: Network activate all plugins when some are already active on a single site + Given a WP multisite install + And I run `wp plugin delete --all` + + When I run `wp plugin install debug-bar` + And I run `wp plugin install wordpress-importer --activate` + Then STDOUT should contain: + """ + Plugin 'wordpress-importer' activated. + """ + + When I run `wp plugin list --fields=name,status` + Then STDOUT should be a table containing rows: + | name | status | + | debug-bar | inactive | + | wordpress-importer | active | + + When I run `wp plugin activate --all --network` + Then STDOUT should contain: + """ + Plugin 'debug-bar' network activated. + """ + And STDOUT should contain: + """ + Plugin 'wordpress-importer' network activated. + """ + And STDOUT should contain: + """ + Success: Network activated 2 of 2 plugins. + """ + + When I run `wp plugin list --fields=name,status` + Then STDOUT should be a table containing rows: + | name | status | + | debug-bar | active-network | + | wordpress-importer | active-network | + Scenario: List plugins Given a WP install diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index ae04e702..587c6d25 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -383,7 +383,9 @@ public function activate( $args, $assoc_args = [] ) { } foreach ( $plugins as $plugin ) { $status = $this->get_status( $plugin->file ); - if ( $all && ! $force && in_array( $status, [ 'active', 'active-network' ], true ) ) { + // When using --all flag, skip plugins that are already in the target state. + $skip_statuses = $network_wide ? array( 'active-network' ) : array( 'active', 'active-network' ); + if ( $all && ! $force && in_array( $status, $skip_statuses, true ) ) { continue; } // Network-active is the highest level of activation status.