-
Notifications
You must be signed in to change notification settings - Fork 80
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
Activation hooks are not run with --activate --force and already activated plugins #390
Comments
I'm open to this, but a little uncertain about it. The change in behavior might be unexpected for existing usage. Should we also add a @schlessera @swissspidy Thoughts? |
Looking down a bit, the extension-command/src/Plugin_Command.php Lines 352 to 361 in 12618c7
But you are right, the actual |
Same here. I wonder what could break here, as it would mean running the activation hook for a plugin that's already active. Plus, would we need to do the same sandboxing as Should rather be the job of plugins like WP Super Cache to detect whether they are correctly set up and provide guidance to users on how to fix issues? |
It isn't really about needing a solution to a particular plugin issue, it is more about the expected behavior of a "force install and activate" command. With this output:
I would expect it to behave the same as if installing a new plugin. Specifically, I'd expect Maybe it is just confusing having the two flags In any case, deactivating the plugin first will cause the hooks to be run again and I'll use that as a work around -- so this isn't a huge problem without a solution. When switching network states, this command already deactivates and the reactivates the plugin, so I assume something similar would happen even if this was implemented. |
I definitely see how that's ambiguous, especially with the wording that doesn't indicate that it's installing an already active plugin. Perhaps we could at least add some info message or something? Just wary of actually running the hook as it could potentially cause issues |
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
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. Runningwp plugin install wp-super-cache --activate --force
will output: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 ofInstalling the plugin...
The text was updated successfully, but these errors were encountered: