Skip to content

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 <bernhard-reiter@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>

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
ockham added a commit that referenced this pull request Feb 20, 2025
* Block Hooks: Fix duplicated insertion in Post Content

* Add backport changelog

* Move function def and filters inside conditional

Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
@ockham
Copy link
Contributor Author

ockham commented Feb 20, 2025

I've cherry-picked 3df54ec to the release/20.0 branch.

Kallyan01 pushed a commit to Kallyan01/gutenberg that referenced this pull request Feb 24, 2025
* Block Hooks: Fix duplicated insertion in Post Content

* Add backport changelog

* Move function def and filters inside conditional

Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
* Block Hooks: Fix duplicated insertion in Post Content

* Add backport changelog

* Move function def and filters inside conditional

Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
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
No open projects
Development

Successfully merging this pull request may close these issues.

2 participants