-
Notifications
You must be signed in to change notification settings - Fork 86
Add warning in wp plugin is-active for missing plugin files still in active_plugins
#480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: swissspidy <[email protected]>
wp plugin is-active for missing plugin files still in active_plugins
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a warning message when wp plugin is-active is run on a plugin that has been manually removed from the filesystem but remains in WordPress's active_plugins or active_sitewide_plugins option. This orphaned state can cause issues with dependency checks and compatibility features in other plugins and WordPress core.
Key Changes
- Modified
Plugin_Command::is_active()to detect orphaned plugin entries by checking the active plugins options when the plugin file is not found - Uses WordPress's
validate_plugin()function to confirm the file is truly missing (and not just filtered) - Emits a helpful warning message while maintaining the existing exit code 1 behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Plugin_Command.php | Added logic to check active_plugins/active_sitewide_plugins options when plugin is not found via fetcher, and emit warning if plugin file doesn't exist but is still marked as active |
| features/plugin-is-active.feature | New test file with scenarios covering active, inactive, missing, and orphaned plugins to verify the warning behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
When a plugin directory is manually removed (not via WP-CLI), the plugin remains in WordPress's
active_pluginsoption. This orphaned entry can break dependency checks and compatibility features in other plugins and core.wp plugin is-activepreviously returned "not active" without indicating this inconsistent state.Changes
Plugin_Command::is_active()to checkactive_plugins/active_sitewide_pluginsoptions when plugin file is not foundvalidate_plugin()to confirm file absencePlugin 'X' is marked as active but the plugin file does not exist.Example behavior:
Tests
features/plugin-is-active.featurewith scenarios covering active, inactive, missing, and orphaned plugins--networkflag behaviorChecklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.