-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
render_block_context
another approach that solve the context issue
#7522
base: trunk
Are you sure you want to change the base?
render_block_context
another approach that solve the context issue
#7522
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
@mukeshpanchal27 Heads up that the tests in #7344 have been updated to reflect the last few comments there. |
Nice one @mukeshpanchal27. @dlh01 and @joemcgill, it looks like all the unit tests we could think of pass in this branch. How do you feel about the proposed solution? Is it good enough to move forward as part of the WP 6.7 release? |
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.
@mukeshpanchal27 This looks very promising. Mostly questions from my end, to make sure I understand this correctly.
Thanks for the ping! I should be able to take a look at this Wednesday or Thursday. |
render_block_context
another approachrender_block_context
another approach that solve the context issue
The PR is ready for review. Address the feedbacks. |
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Ah I see what you're saying, yes. Probably the method should be parameterless and simply update the other properties based on the current values of the updated properties. |
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.
@mukeshpanchal27 Holding off of my previous approval based on the valid points raised in #7522 (comment) and related comments.
For instance:
- We don't need to pass the values for the properties to the
WP_Block
class methods, as the filters update the values for these properties in place. - We should separate the updates into two methods: One that updates data based on the
parsed_block
and another that updates data based on thecontext
. This way we can also be more efficient about the check for whether the value changed: We only need to make updates to the two groups of dependent properties if that one property (parsed_block
orcontext
) changed.
I've spent some time addressing the feedback, and I would appreciate your input before I proceed with fixing the unit tests.
Some of the existing unit tests are failing. Below are the details:
|
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.
@mukeshpanchal27 Technically this almost looks good, just one problem to address (and then the failing tests).
I think we need to revise the method naming though, and their documentation as well, as it is now no longer correct.
@felixarntz @joemcgill @dlh01 @gziolo The PR is ready for review. |
I take another pass and try to find the the solution to not merge the |
@felixarntz @joemcgill @dlh01 @gziolo In c83ca82, I removed the context merging from Currently, there’s only one uncovered case: when a block needs context for itself, not for nested blocks. The In the single block case, the Would it be acceptable to remove the failing unit test and merge this PR, as it resolves the ancestor block context issue? We can then open a follow-up discussion to address the remaining part. |
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.
@mukeshpanchal27 This looks almost there for me, just one note.
|
||
/** This filter is documented in wp-includes/blocks.php */ | ||
$inner_block->parsed_block = apply_filters( 'render_block_data', $inner_block->parsed_block, $source_block, $parent_block ); | ||
|
||
/** This filter is documented in wp-includes/blocks.php */ | ||
$inner_block->context = apply_filters( 'render_block_context', $inner_block->context, $inner_block->parsed_block, $parent_block ); | ||
|
||
if ( $inner_block->context !== $inner_block_context ) { | ||
$inner_block->available_context = array_merge( $this->available_context, $inner_block->context ); |
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.
This line doesn't look right to me. If we want to update $available_context
based on $context
, this should happen within the refresh_context_dependents()
because then $available_context
is a dependent of $context
.
Trac ticket: https://core.trac.wordpress.org/ticket/62046
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.