-
Notifications
You must be signed in to change notification settings - Fork 86
Description
Feature Request
When running wp plugin install plugin --activate --force
It won't run activation hooks if the plugin is already activated:
extension-command/src/Plugin_Command.php
Lines 352 to 356 in 12618c7
| // Don't reactivate active plugins, but do let them become network-active. | |
| if ( ! $network_wide && 'active' === $status ) { | |
| WP_CLI::warning( "Plugin '{$plugin->name}' is already active." ); | |
| continue; | |
| } |
It would be nice if --force also triggered the activation hooks, because it is possible for a plugin to be activated but in a weird state where the activation hooks can fix it.
As an example:
WP Super Cache installs an advanced-cache.php dropin when activated. If something deletes that file, the plugin can be activated but now not work properly. Running wp plugin install wp-super-cache --activate --force will output:
Installing WP Super Cache (1.11.0)
Downloading installation package from https://downloads.wordpress.org/plugin/wp-super-cache.1.11.0.zip...
Unpacking the package...
Installing the plugin...
Removing the old version of the plugin...
Plugin updated successfully.
Which makes it seem like a full replacement, but it won't recreate advanced-cache.php because it doesn't actually run the activation hooks anywhere above. If you deactivate the plugin first and then run the command, it will run the activation hooks and recreate it. But then you have any side effects that might come from deactivating it. I think it would make sense if the existing --force option also bypassed the check above and cause it to run the activation hooks again as part of Installing the plugin...