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

Block Hooks: Fix duplicated insertion in Post Content #69142

Merged
merged 3 commits into from
Feb 14, 2025

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Feb 11, 2025

What?

In the editor, hooked blocks are currently inserted twice into post content (when using the GB plugin on a WP trunk install).
This was likely introduced by #67272 and its Core counterpart, [59523]. It was probably not discovered earlier as it requires testing GB against Core trunk.

Likely also affects Synced Patterns (#68058 and [59543]), which are also fixed by this PR.

Discovered while working on #69044, which is adding e2e test coverage for this exact scenario (and others).

Why?

It's a bug 🤷‍♂️

How?

By removing the insert_hooked_blocks_into_rest_response filter before adding GB's own version, gutenberg_insert_hooked_blocks_into_rest_response.

Testing Instructions

This is covered by end-to-end tests introduced by #69044. Follow that PR's instructions to run tests locally, and cherry-pick the commit from this PR on top to verify that it fixes the issue.

@ockham ockham self-assigned this Feb 11, 2025
@ockham ockham added [Type] Bug An existing feature does not function as intended [Feature] Block hooks labels Feb 11, 2025
@ockham ockham force-pushed the fix/block-hooks-double-insertion-in-post-content branch from 6e27775 to 9750de5 Compare February 13, 2025 21:40
@ockham ockham marked this pull request as ready for review February 13, 2025 21:40
@ockham ockham requested a review from spacedmonkey as a code owner February 13, 2025 21:40
Copy link

github-actions bot commented Feb 13, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ockham <[email protected]>
Co-authored-by: gziolo <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ockham ockham requested a review from gziolo February 13, 2025 21:41
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

This looks good to go. Apologies for all accidental pings. I wanted to test the changes with new e2e tests by pointing the base branch to the other PR 😅

@gziolo gziolo merged commit 3df54ec into trunk Feb 14, 2025
84 checks passed
@gziolo gziolo deleted the fix/block-hooks-double-insertion-in-post-content branch February 14, 2025 10:07
@github-actions github-actions bot added this to the Gutenberg 20.4 milestone Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block hooks [Type] Bug An existing feature does not function as intended
Projects
Development

Successfully merging this pull request may close these issues.

2 participants