Skip to content

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

Open
@kkmuffme

Description

@kkmuffme

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()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions