Skip to content

Fix --all --network to network-activate single-site active plugins#499

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/fix-network-activation-issue
Draft

Fix --all --network to network-activate single-site active plugins#499
Copilot wants to merge 5 commits intomainfrom
copilot/fix-network-activation-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

The --all flag was skipping plugins with status active or active-network regardless of the target activation state. This prevented wp plugin activate --all --network from network-activating plugins that were only active on a single site.

Changes

  • src/Plugin_Command.php: Modified skip condition to be context-aware:
    • --all --network: skip only active-network plugins
    • --all: skip only active plugins
// Before: skipped both active and active-network with --all
if ( $all && in_array( $status, [ 'active', 'active-network' ], true ) ) {
    continue;
}

// After: skip based on target state
if ( $all && ( ( $network_wide && 'active-network' === $status ) || ( ! $network_wide && 'active' === $status ) ) ) {
    continue;
}
  • features/plugin.feature: Added test scenario verifying --all --network properly network-activates single-site active plugins

The existing deactivation logic (lines 392-394) already handles transitioning from single-site active to network-active, so this change allows that code path to execute correctly.

Original prompt

This section details on the original issue you should resolve

<issue_title>--all --network flag combination incorrectly skips plugins that are active but not network-active</issue_title>
<issue_description>## Bug Report

Describe the current, buggy behavior

When running wp plugin activate --all --network, the command skips any plugin that is already active (even if only on a single site) due to this check in the code:

if ( $all && in_array( $status, [ 'active', 'active-network' ], true ) ) {
continue;
}

This results in the command not network-activating any plugins that are already active on a single site, even though they're not network-active.

Describe how other contributors can replicate this bug

  1. Set up a WordPress multisite
  2. Activate some plugins on a single site (not network-wide)
  3. Run wp plugin activate --all --network
  4. Observe that already-active plugins are skipped and not network-activated

Describe what you would expect as the correct outcome

The --all --network combination should only skip plugins that are already network-active. Plugins that are active on a single site should be deactivated and then network-activated.

Let us know what environment you are running this on
wp-env:

OS:	Linux 6.10.14-linuxkit wp-cli/extension-command#1 SMP Thu Mar 20 16:32:56 UTC 2025 aarch64
Shell:	
PHP binary:	/usr/local/bin/php
PHP version:	8.2.28
php.ini used:	/usr/local/etc/php/php.ini
MySQL binary:	/usr/bin/mariadb
MySQL version:	mariadb from 11.4.5-MariaDB, client 15.2 for Linux (aarch64) using readline 5.1
SQL modes:	
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	phar:///usr/local/bin/wp
WP-CLI packages dir:	
WP-CLI cache dir:	/home/kaspernowak/.wp-cli/cache
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.12.0
✔ Ran `wp cli info` in 'cli'. (in 1s 96ms)

Provide a possible solution

Modify the check to only skip plugins that are already network-active:

if ( $all && 'active-network' === $status ) {
    continue;
}

This would allow the command to network-activate plugins that are only active on a single site.
</issue_description>

Comments on the Issue (you are @copilot in this section)

@swissspidy Looks like this was added 9 years ago in 6dbca8a

Don't erroneously try to (de)activate plugins with --all flag
When the --all flag is provided, we should only try to activate
plugins that aren't active, and deactivate plugins that are active.

It didn't add any multisite-related tests though, so not sure whether that was considered.

Plugins that are active on a single site should be deactivated and then network-activated.

We already do this when not using --all, so I wonder why --all was handled differently in that commit.

// Plugins need to be deactivated before being network activated.
if ( $network_wide && 'active' === $status ) {
deactivate_plugins( $plugin->file, false, false );
}
</comment_new>
<comment_new>@swissspidy
I don‘t know :-) Maybe someone else can chime in on that</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@github-actions github-actions bot added command:plugin-activate Related to 'plugin activate' command scope:testing Related to testing labels Feb 12, 2026
…ive plugins

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug with network activation of plugins Fix --all --network to network-activate single-site active plugins Feb 12, 2026
Copilot AI requested a review from swissspidy February 12, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:plugin-activate Related to 'plugin activate' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--all --network flag combination incorrectly skips plugins that are active but not network-active

2 participants