-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Only start main query loop when block template is associated with the current theme #5575
Conversation
I have tested the PR and it fixes the issue. Thanks @felixarntz |
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.
Thanks for the quick work on this @felixarntz! I've left a few thoughts.
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.
Thank you, @felixarntz, for the quick PR. It looks solid to me.
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.
Thanks @felixarntz! LGTM 👍
Cross-sharing a test report from the ticket: WooCommerce Blocks had a related issue, which is fixed by this PR ✅ |
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.
LGTM 👍 Ready for commit and backport.
Committed in https://core.trac.wordpress.org/changeset/57019 |
Generally, the block template loaded should always be associated with the current theme since:
WP_Query
that filters to block templates only for theget_stylesheet()
themeIn both cases, the template ID will begin with
get_stylesheet() . '//'
.There are rare situations (e.g. the https://wordpress.org/plugins/echo-knowledge-base/ plugin as reported in the Trac ticket) where a plugin hijacks the block template loading mechanism to inject its own block template, which thus comes from outside the theme and may use any logic. In those cases, the situation is unpredictable by core and therefore the assumption that no main query loop will be present for a singular
WP_Query
is no longer reliable. As such, in those cases no main query loop should be started, as that would lead to problems if the custom logic was going to attempt to start the main query loop itself. So for those cases, the PR simply falls back to the original pre-6.4 logic of just parsing blocks.Trac ticket: https://core.trac.wordpress.org/ticket/59736
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.