Skip to content

Conversation

@andrewserong
Copy link
Contributor

@andrewserong andrewserong commented Oct 27, 2022

What?

Follow-up to: #44600

When using WP_HTML_Tag_Processor in layout.php, we need to make sure that we cast to a string, otherwise we return a WP_HTML_Tag_Processor object instead of a string. Although it can be treated as a string, if we have other hooks that also act on the block content and that are registered after the existing layout support, then without this change, they can accidentally encounter an object instead of a string.

Why?

While rebasing #44723, I ran into a PHP fatal when I attempted to do more processing in an additional hook on render_block because the $block_content was not a string as expected. This change should resolve that.

How?

Add (string) casts before output when using WP_HTML_Tag_Processor in layout.php

Testing Instructions

Smoke test and ensure that layout output is still working as expected (e.g. add a few group blocks to a page, set some block spacing, save, and view on site front-end, and ensure there are no PHP errors or warnings)

@andrewserong andrewserong added [Type] Bug An existing feature does not function as intended [Feature] Layout Layout block support, its UI controls, and style output. labels Oct 27, 2022
@andrewserong andrewserong self-assigned this Oct 27, 2022
Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

LGTM!

@andrewserong andrewserong merged commit f2f4e21 into trunk Oct 27, 2022
@andrewserong andrewserong deleted the fix/small-tweaks-after-inner-blocks-changes-for-layout branch October 27, 2022 05:27
@andrewserong
Copy link
Contributor Author

Thanks for the quick review! 🙇

@github-actions github-actions bot added this to the Gutenberg 14.5 milestone Oct 27, 2022
@tellthemachines
Copy link
Contributor

Thanks for fixing this 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Layout Layout block support, its UI controls, and style output. [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants