Prevent that runtime checks are allowed in CLI context when they cannot be used #598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
Abstract_Check_Runner::get_checks_to_run()
method has logic to determine whether to allow runtime checks, depending on the environment. Generally, runtime checks can only be used if theobject-cache.php
drop-in is already present (which will lead to early initialization) or if we know that theobject-cache.php
file can be placed.This works as expected for the WP Admin flow, but not for WP-CLI: In WP-CLI, everything happens in a single request, so we can't just place the
object-cache.php
drop-in later. This means PCP will currently attempt to include runtime checks in WP-CLI context even when it should not.This PR fixes this by moving the logic into its own method, which the
CLI_Runner
class then overrides to make the logic "stricter": It can only use runtime checks if theobject-cache.php
drop-in is already present, i.e. the runner was initialized early.