Add —force-check flag to wp plugin list and wp theme list. (wip)#399
Add —force-check flag to wp plugin list and wp theme list. (wip)#399baizmandesign wants to merge 0 commit intowp-cli:mainfrom
wp plugin list and wp theme list. (wip)#399Conversation
features/plugin-list.feature
Outdated
| @@ -0,0 +1,56 @@ | |||
| Feature: List WordPress plugins | |||
|
|
|||
| Scenario: Refresh update_plugins transient when listing plugins with --force-check flag | |||
There was a problem hiding this comment.
@baizmandesign What do you think of this Behat test refactor?
There was a problem hiding this comment.
I ran the behat tests, and they worked for me! Very exciting. A couple comments:
- I'm unclear why the
wp plugin list --fields=name,status,updatecommand needs to be run twice afterupdate-transient.phpis executed. - Is it an issue that the version of the Hello Dolly plugin, 1.7.2, is hard-coded in the test?
src/WP_CLI/CommandWithUpgrade.php
Outdated
| if ( true === (bool) Utils\get_flag_value( $assoc_args, 'force-check', false ) ) { | ||
| delete_site_transient( $this->upgrade_transient ); | ||
| } | ||
|
|
There was a problem hiding this comment.
What should happen if someone uses --force-check and --skip-update-check at the same time?
There was a problem hiding this comment.
Hi @danielbachhuber,
That's a good question. As currently written, --force-check is toothless if --skip-update-check is also passed to the command.
Here are a couple of proposals for resolving this matter (assuming we're solely talking about plugins, as an example):
- Let the code for both functions execute—delete the plugin transient and skip the call to
wp_update_plugins()—and issue a warning: "Plugin updates were requested to be force-checked and were not checked due to the --skip-update-check argument." - Make it so that the two options are mutually exclusive: you can run either one or the other. Running both results in an error: "Plugins cannot be both force-checked and skipped. Choose one."
- Let one command always "over-rule" the other. For example, we might decide that
--skip-update-checkshould always prevail if both are present. It can proceed quietly (and not delete the plugin transient) or issue a warning ("Plugin updates were not force-checked due to the --skip-update-check argument."). On the other hand, we could decide that--force-checkalways over-rules--skip-update-check.
I think I'm partial to option 2 but can be convinced of choosing one of the other options (or alternatives unmentioned above).
Thoughts?
There was a problem hiding this comment.
Sounds good, @danielbachhuber! I'll get to work on implementing the error and the theme version of the flag.
118fca6 to
f9bc3fd
Compare
Hi @danielbachhuber,
Here's the work-in-progress pull request that you asked me to submit. Please see our comment thread on wp-cli/ideas for the history of our exchange regarding challenges creating tests for this new flag.
Please let me know if I can help in any other way.
Saul
PS. The contents of
features/theme-list.featurecan be ignored and likely needs to be completely rewritten. My plan was to work infeatures/plugin-list.featureand get that right first, then I was going to copy and paste any working code and replace "plugin" with "theme" where needed infeatures/theme-list.feature. But as you know things didn't proceed that far.