[wp-trac] [WordPress Trac] #62639: Block Hooks: Wrongly typed context when updating wp_navigation post meta

WordPress Trac noreply at wordpress.org
Tue Dec 3 16:48:00 UTC 2024


#62639: Block Hooks: Wrongly typed context when updating wp_navigation post meta
-----------------------------+--------------------
 Reporter:  Bernhard Reiter  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  6.7.2
Component:  General          |    Version:  trunk
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+--------------------
 `update_ignored_hooked_blocks_postmeta` passes a `$context` argument to
 `apply_block_hooks_to_content` that is used by the `hooked_block_types`,
 `hooked_block`, and `hooked_block_{$hooked_block_type}` filters, if any.

 Those filters allow extenders to conditionally insert hooked blocks, based
 on criteria that might involve the `$context` argument. For example, a
 filter might check `if ( $context instanceof WP_Post && 'wp_navigation'
 === $context->post_type )` to limit insertion of a hooked block to
 Navigation blocks only.

 While other functions that also call `apply_block_hooks_to_content` pass a
 correctly typed `$context`, `update_ignored_hooked_blocks_postmeta` passes
 a `stdObject` rather than a `WP_Post` instance. As a result, a criterion
 like in the above filter example will fail -- thus not correctly setting
 `ignoredHookedBlocks` metadata for the `wp_navigation` post object in
 question.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62639>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list