Skip to content
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

Prevent that runtime checks are allowed in CLI context when they cannot be used #598

Merged

Conversation

felixarntz
Copy link
Member

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 the object-cache.php drop-in is already present (which will lead to early initialization) or if we know that the object-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 the object-cache.php drop-in is already present, i.e. the runner was initialized early.

@felixarntz felixarntz added the [Type] Bug An existing feature is broken label Aug 30, 2024
@felixarntz felixarntz added this to the 1.2.0 milestone Aug 30, 2024
Copy link

github-actions bot commented Aug 30, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: felixarntz <flixos90@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: ernilambar <rabmalin@git.wordpress.org>
Co-authored-by: davidperezgar <davidperez@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@ernilambar ernilambar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could fix n.e.x.t since version in bulk in the time of new release. Lets not hold this now for that issue.

@ernilambar ernilambar merged commit 7e5bcd9 into trunk Sep 2, 2024
25 checks passed
@ernilambar ernilambar deleted the fix/prevent-runtime-checks-incorrectly-allowed-in-cli branch September 2, 2024 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature is broken
5 participants