-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add context property mapping to block registration #23180
Conversation
Size Change: 0 B Total Size: 1.13 MB ℹ️ View Unchanged
|
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.
Works like a charm! Thanks Noah 🙇
trying to get the tests to pass. it shouldn't be related at all |
wtf travis |
@@ -169,6 +169,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { | |||
$property_mappings = array( | |||
'title' => 'title', | |||
'category' => 'category', | |||
'context' => '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.
I guess we need to add providesContext
, too :)
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.
fixed in #23212
@ockham Why wasa this merged. Either of the REST API team signed off and this change is wrong. REST API already has a context value and can be used for something else. |
At the moment, it's correct since Gutenberg relays on |
My apologies, I might not be very familiar with this code, but the fix seemed to make sense and fixed the issue we were seeing. I also wasn't aware it affected the REST API, or that it needed sign-off by the REST API team. Could you elaborate why the change is wrong, and what policy we should observe with regard to sign-off by individual teams? |
Travis passed and this fixes a bug where blocks would not render on the front end if they relied on block context. (the change which introduced the property mapping mechanism basically stopped a block from registering the context it needs.) So it's more of a hotfix :) Maybe we need more strict checks to make sure that PRs affecting API are not merged without sign-off from the API team? |
So what's the follow-up here? It looks like we might need to:
|
@spacedmonkey name fixed in #23212 |
Fixes #23179
Description
Block context was not being parsed in block registration.
This broke dynamic blocks which relied on
$block->context
. The context properties were not being added to context from available_context because it only adds properties which existed in the block metadata... and context was not parsed inHow has this been tested?
Locally.
Screenshots
Before:
After: (ignore the echo; it was for debugging)
Types of changes
Bug fix
Checklist: