[wp-trac] [WordPress Trac] #63287: Unexpected output from apply_block_hooks_to_content_from_post_object
WordPress Trac
noreply at wordpress.org
Fri Apr 25 19:21:46 UTC 2025
#63287: Unexpected output from apply_block_hooks_to_content_from_post_object
-------------------------------------------------+-------------------------
Reporter: obenland | Owner: bernhard-
| reiter
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.8.1
Component: Editor | Version: 6.8
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests fixed- | Focuses:
major |
-------------------------------------------------+-------------------------
Changes (by jorbin):
* status: reopened => closed
* resolution: => fixed
Comment:
In [changeset:"60189" 60189]:
{{{
#!CommitTicketReference repository="" revision="60189"
Block Hooks: Suppress insertion next to post content wrapper block.
As of [59523], Block Hooks are applied to post content. In order to allow
for insertion of a hooked block as first_child or last_child of the
containing Post Content block, we wrap the block's post content (as
obtained from the DB) in a temporary <!-- wp:post-content --> wrapper
block, apply the Block Hooks algorithm to the resulting markup, and remove
the wrapper block. (The same technique is applied for the Synced Pattern
block -- see [59543] -- as well as the Navigation block.)
However, this caused a problem when a hooked block was marked for
insertion before before or after a Post Content block: The logic that's
supposed to remove the temporary wrapper block after the Block Hooks
algorithm runs erroneously removed that hooked block's delimiter instead
of the wrapper block, producing garbled markup as a result.
This changeset fixes the issue by adding a hooked_block_types filter (with
PHP_INT_MAX priority) that removes any blocks hooked before or after a
Post Content block, if the current context is a post object. This prevents
any blocks hooked that way from being "absorbed" into the corresponding
post object's content; it retains the ability to hook blocks before and
after a Post Content block in any other context (e.g. a template). (The
same principle is applied to Synced Pattern and Navigation blocks.)
Reviewed by Jorbin.
Merges [60173] to 6.8 branch.
Props obenland, jorbin, gziolo, bernhard-reiter.
Fixes #63287.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63287#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list