-
Notifications
You must be signed in to change notification settings - Fork 53
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
CLI: Fix confusing runtime environment setup order #749
Conversation
…cution for WP-CLI and simplify WP-CLI command implementation accordingly.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
…erate_password().
…_install() to be available.
…when database is present.
… this is no longer being logged by the CLI command.
… this is no longer being logged by the CLI command.
It took me a while to get the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate all the digging into this! 👏
Awesome! |
Related to #597.
As of today, in WP-CLI the
Runtime_Environment_Setup
sets up the separate database tables after all the regular preparations have run (i.e.Universal_Runtime_Preparation
). This is confusing and inconsistent with how it works in the AJAX based workflow, where theRuntime_Environment_Setup
is executed in a previous request. This is how it was intended, as ideally setting up the separate database tables to run runtime checks against needs to be the earliest step. However, in WP-CLI this has not been happening so far, because it was invoked by the command implementation itself, which however is executed after the early initialization process.For example, today the
option_active_plugins
filter is applied on the real database tables for WP-CLI, which means the separate database tables will only contain the filtered plugins. In the AJAX based flow on the other hand, all active plugins from the real database tables will be added to the separate database tables, and theoption_active_plugins
filter is only applied then. This is, to my knowledge, not causing an actual problem today, but it's just strange and error-prone to have to consider both execution orders.I had mentioned in this comment that it's "just a technical nuance", but it's still weird and inconsistent, and it doesn't have to be.
This PR fixes it:
Abstract_Check_Runner
class to a new protected methodinitialize_runtime()
.CLI_Runner
, override that method to first executeRuntime_Environment_Setup
, and of course also add its cleanup callback to the list of callbacks.Plugin_Check_Command
class:Runtime_Environment_Setup
since it's now handled byCLI_Runner
.has_runtime_check()
method, as well as an extra call to theget_checks_to_run()
method which only existed for that purpose.It now all works through the
CLI_Runner
, i.e. less technical and cognitive overhead for thePlugin_Check_Command
implementation.