Skip to content
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 null check to prevent errors in get_block_template filter #60491

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/compat/wordpress-6.6/resolve-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ function gutenberg_replace_pattern_blocks_get_block_templates( $templates ) {
}

function gutenberg_replace_pattern_blocks_get_block_template( $template ) {
if ( null === $template ) {
return $template;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me that sounds like there's a bug in the get_block_template filter, which should be called at all for null.

$blocks = parse_blocks( $template->content );
$blocks = gutenberg_replace_pattern_blocks( $blocks );
$template->content = serialize_blocks( $blocks );
Expand Down
Loading