Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
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()