-
Notifications
You must be signed in to change notification settings - Fork 85
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 <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>
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 <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
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>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
/gemini review |
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.
Code Review
This pull request enhances the wp plugin is-active command to detect and warn about 'orphaned' plugins—plugins that have been manually deleted from the filesystem but still exist in the WordPress database's active plugins list. The change correctly identifies this inconsistent state for both single-site and multisite installations and emits a warning, improving the command's accuracy without changing its exit code behavior for inactive plugins. The implementation is well-tested with new feature tests covering various scenarios. My feedback includes a minor suggestion to improve code clarity and maintainability by removing redundant checks.
| ( ! empty( $input_name ) && "$input_name.php" === $plugin_file ) || | ||
| ( ! empty( $input_name ) && $plugin_file === $input_name ) || | ||
| ( ! empty( $input_name ) && dirname( $plugin_file ) === $input_name && '.' !== $input_name ) |
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.
These ! empty( $input_name ) checks appear to be redundant. The <plugin> argument is required for this command, so $input_name (from $args[0]) should always be a non-empty string. Removing these checks will simplify the condition.
On a related note, this logic for finding a plugin by name is duplicated from WP_CLI\Fetchers\Plugin::get(). For future refactoring, it would be beneficial to extract this into a shared helper to improve maintainability.
"$input_name.php" === $plugin_file ||
$plugin_file === $input_name ||
( dirname( $plugin_file ) === $input_name && '.' !== $input_name )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.
@copilot address #480 (comment)
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.