Skip to content

Add warning in wp plugin is-active for missing plugin files still in active_plugins#480

Merged
swissspidy merged 12 commits intomainfrom
copilot/fix-active-plugins-check
Feb 5, 2026
Merged

Add warning in wp plugin is-active for missing plugin files still in active_plugins#480
swissspidy merged 12 commits intomainfrom
copilot/fix-active-plugins-check

Conversation

Copy link
Contributor

Copilot AI commented Dec 14, 2025

Implementation Complete

  • Understand the current is_active implementation and how it checks plugin status
  • Modify is_active to check if plugin is in active_plugins option even when file doesn't exist
  • Add warning when plugin file doesn't exist but is still in active_plugins using validate_plugin()
  • Create Behat tests to verify the warning is emitted correctly
  • Add documentation for the new behavior
  • Run linting and static analysis (all passing: lint, phpcs, phpstan)
  • Address code review feedback
  • Fix failing test scenario
  • Add test for network-activated plugins with missing files
  • Remove redundant empty checks (plugin argument is required)

Summary

This PR implements a warning in wp plugin is-active when a plugin file has been manually removed but is still present in the active_plugins option. The implementation:

  • Checks both regular and network-wide active plugins
  • Uses validate_plugin() to confirm file is missing
  • Emits a clear warning message
  • Returns exit code 1 (not active) as expected
  • Does NOT make any destructive changes

All quality checks pass and comprehensive tests are included for both single-site and multisite scenarios.

Original prompt

This section details on the original issue you should resolve

<issue_title>is-active/deactivate should also check the "active_plugins" option</issue_title>
<issue_description>## Bug Report

Describe the current, buggy behavior

When a plugin file/directory is removed by the user (and not by WP), the "active_plugins" option will still contain that plugin.
Various plugins (and WP core?) use this "active_plugins" option for dependency checks, loading of compatibitility data,...

However wp plugin is-active and wp plugin deactivate will report that the plugin isn't active/the plugin could not be found.

WP core has a function https://developer.wordpress.org/reference/functions/validate_active_plugins/ to update this option (and deactivate all those not found ones), however it will deactivate ALL of those plugins, not necessarily only the one passed to CLI. However it's trivial copy and port that to CLI.

Describe how other contributors can replicate this bug

wp plugin activate whatever
rm -rf wp-content/plugins/whatever
wp plugin deactivate whatever
wp eval "echo array_values( preg_grep( '#^whatever#', get_option( 'active_plugins' ) ) )[0];"

Describe what you would expect as the correct outcome

is-active and deactivate should deactivate the plugin if it's still in active_plugins but the directory does not exist.

Provide a possible solution

See validate_active_plugins()</issue_description>

<agent_instructions>wp plugin is-active should emit a warning if the plugin does not exist but is still in the active_plugins option. This can be done by using the validate_plugin option provided by WordPress</agent_instructions>

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

@swissspidy Updating `wp plugin deactivate` sounds reasonable at first glance, but we shouldn't change `is-active` to make destructive actions. That sounds very unexpected when you just want to check the status. @swissspidy What about `wp plugin is-active` emitting a warning if the plugin does not exist but is still in the `active_plugins` option?

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 14, 2025 21:00
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix is-active/deactivate to check active_plugins option Add warning in wp plugin is-active for missing plugin files still in active_plugins Dec 14, 2025
Copilot AI requested a review from swissspidy December 14, 2025 21:09
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 3 commits December 14, 2025 22:37
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy marked this pull request as ready for review December 14, 2025 22:03
@swissspidy swissspidy requested a review from a team as a code owner December 14, 2025 22:03
@codecov
Copy link

codecov bot commented Dec 14, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Plugin_Command.php 88.88% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions github-actions bot added command:plugin-is-active Related to 'plugin is-active' command scope:documentation Related to documentation labels Dec 22, 2025
@github-actions github-actions bot added the scope:testing Related to testing label Dec 22, 2025
@swissspidy swissspidy added this to the 2.3.0 milestone Dec 22, 2025
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy merged commit a096871 into main Feb 5, 2026
43 of 44 checks passed
@swissspidy swissspidy deleted the copilot/fix-active-plugins-check branch February 5, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:plugin-is-active Related to 'plugin is-active' command scope:documentation Related to documentation scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is-active/deactivate should also check the "active_plugins" option

2 participants