[wp-trac] [WordPress Trac] #59551: Respect non-null values from the `pre_render_block` filter

WordPress Trac noreply at wordpress.org
Thu Oct 5 18:09:05 UTC 2023


#59551: Respect non-null values from the `pre_render_block` filter
--------------------------+-----------------------------
 Reporter:  danieliser    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Currently WP core hooks into `pre_render_block` in 2 places.

 In both cases they hook in at `priority` `10`, and in both cases they
 explicitly return null.

 This means anybody following the example usage of that filter could end up
 with their return not respected unless they change priority to higher than
 10, which is not documented.

 Either those filters should be moved to an earlier priority, such as `0`,
 or they should expect & respect non-nullish values by not returning `null`
 and instead returning `$pre_render`.

 Further if these are conditional loads based on block type, they should
 probably check if `! is_null( $pre_render )` and if so, act accordingly
 and not enqueue assets or bail early etc.

 - https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-
 includes/block-supports/settings.php#L77-L149

 - https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-
 includes/block-supports/elements.php#L135-L222

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


More information about the wp-trac mailing list