-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix context injection loop #26998
Fix context injection loop #26998
Conversation
* @param array $parsed_block Block being rendered, filtered by `render_block_data`. | ||
*/ | ||
$context = apply_filters( 'render_block_context', $context, $parsed_block ); | ||
if ( isset( $wp_query->tax_query->queried_terms['post_tag'] ) ) { |
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.
@ntsekouras I'm not sure I understand why we need to inejct the "query" context here. This compact function should be only used to implement the context support behavior and not inject things into the context. unless, these are "default injections" things that should be injected to all blocks?
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.
The first injection for categories
was from Enrique and when I implemented the tags
support followed that lead, without digging deep. After some more recent explorations with context (without being sure yet), I believe this was implemented by Enrique to make the QueryLoop
inherit global context if is not wrapped by Query
block.
I believe this used to work for the above case (not wrapped in Query), but many changes to many things (like FSE navigation, context, Query etc) made it not to use these values.
For me this code is a part to the exploration of inheriting global context to Query block, but it's not clear to me how to handle this.
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.
@ntsekouras Would you be able to check that everything works properly for the query block in 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.
Query works fine, but I said above, I think this is some leftover code that needs reworking as a part of global context inheritance problem.
-- I tested with my change in the suggestion for the typo qery
-> query
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.
yeah, that's fine, I'm just making sure I don't regress anything and fix the currently failing e2e tests. Thanks for testing.
Size Change: 0 B Total Size: 1.19 MB ℹ️ View Unchanged
|
It seems my fix here is not good enough, I think we regressed on block context. |
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
So this seems to fix most of the end2end tests. There are some remaining failures which I believe were introduced by #26903 |
This refactors the context injection to rely on register_block_type hook instead, that way it's less dependent on the implementation of the block rendering in Core.
This is intended to fix the current e2e failures.