Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#65759 new defect (bug)

Plugin Dependencies: a network-activated dependency is counted as inactive, disabling the Activate button

Reported by: courane01 Owned by:
Priority: normal Milestone: Awaiting Review
Component: Plugins Version: 6.5
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses: multisite

Description

On multisite, when a plugin's dependency is network-activated, wp_get_plugin_action_button() counts that dependency as inactive and renders a disabled Activate button. The dependency is genuinely active, and is_plugin_active() reports it as such.

Cause

In wp-admin/includes/plugin-install.php, wp_get_plugin_action_button() builds its dependency check from the current site's option only:

$active_plugins = get_option( 'active_plugins', array() );

Network-activated plugins are stored in the active_sitewide_plugins site option and never appear in a subsite's active_plugins, so $all_plugin_dependencies_active evaluates to false.

Note the inconsistency within the same function: the target plugin's own state is resolved with is_plugin_active(), which does consult is_plugin_active_for_network(). The AJAX validation path in WP_Plugin_Dependencies also handles network activation correctly. The gap is limited to the dependency count used for this button.

Steps to reproduce

  1. Set up a multisite network.
  2. Network-activate a plugin (reproduced with both WooCommerce and Classic Editor).
  3. As a Super Admin, view a plugin that declares Requires Plugins: naming that dependency.

Observed state on a subsite:

is_plugin_active( 'classic-editor/classic-editor.php' )  = true
in_array( ..., get_option( 'active_plugins' ) )          = false
isset( get_site_option( 'active_sitewide_plugins' )[...] ) = true

Rendered output:

<button type="button" class="button button-compact button-disabled"
        disabled="disabled">Activate</button>

In Network Admin with WooCommerce network-activated, the plugin card shows "Additional plugins are required", lists WooCommerce as the requirement, and disables the Network Activate button. Screenshot attached.

Expected

A dependency that is active network-wide should satisfy the requirement, and the Activate button should be enabled.

Impact

On multisite, a plugin whose dependency is already satisfied network-wide cannot be activated from this screen. Present since Plugin Dependencies shipped in 6.5, and still present in 7.1-beta4.

Related: #63942 fixed the sibling issue where the row action label read "Deactivate" instead of "Network Deactivate" for network-active plugins with dependencies. This is the same network-activation blind spot in the action button's dependency calculation.

Tested on 7.1-beta4, PHP 7.4, subdirectory multisite with 11 sites.

Attachments (1)

wp71-plugin-dependency-ui-wide.png (108.3 KB ) - added by courane01 6 weeks ago.
Network Admin > Plugins > Add New on WP 7.1-beta4 multisite, with WooCommerce network-activated. The card shows "Additional plugins are required", lists WooCommerce as the requirement, and the Network Activate button is disabled even though the dependency is active network-wide.

Download all attachments as: .zip

Change History (2)

@courane01
6 weeks ago

Network Admin > Plugins > Add New on WP 7.1-beta4 multisite, with WooCommerce network-activated. The card shows "Additional plugins are required", lists WooCommerce as the requirement, and the Network Activate button is disabled even though the dependency is active network-wide.

This ticket was mentioned in PR #12782 on WordPress/wordpress-develop by @benitoalba.


5 weeks ago
#1

  • Keywords has-patch has-unit-tests added

## Summary

wp_get_plugin_action_button() only checked the per-site active_plugins option when determining whether plugin dependencies were active. On multisite, this caused the Activate button to remain disabled when a dependency was network-active.

This changes the dependency check to use is_plugin_active(), which recognizes both per-site and network activation, and adds a multisite regression test.

## Testing

  • Focused multisite regression test: 1 test, 3 assertions
  • Complete action-button test class on multisite: 3 tests, 7 assertions
  • Complete action-button test class on single site: 3 tests, 6 assertions
  • PHP coding standards on both changed files
  • git diff --check

## Use of AI Tools

AI assistance: Codex assisted with drafting the code and tests. I reviewed and validated the changes and completed the remaining contribution work.

Note: See TracTickets for help on using tickets.