-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Template Part block: Guard against get_block_file_template
returning null
#69309
Conversation
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.
35821a7
to
1e47524
Compare
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Flagging this for inclusion in WP 6.8 @Mamaduka @fabiankaegy 🙂 |
…g `null` (#69309) Co-authored-by: ockham <[email protected]> Co-authored-by: paulopmt1 <[email protected]> Co-authored-by: josephscott <[email protected]>
I've cherry-picked ac34493 to the |
Thanks, @ockham! |
What?
Add a guard to ensure
$block_template->content
exists before assigning its value to a variable.Why?
The Template Part PHP code uses
get_block_file_template()
to fetch information about the given template part from the corresponding theme's block template file. However, that function can returnnull
, and the code currently guard against that when attempting to get the returned$block_template
object's->content
field.How?
See above.
By keeping
$content
set to its initialnull
, a later check in the Template Part block code will issue a more user-friendly warning.Testing Instructions
<!-- wp:template-part {"slug":"post-meta"} /-->
Screenshots or screencast