[wp-trac] [WordPress Trac] #56923: register_block_core_template_part does WP_Query even on themes that do not support it

WordPress Trac noreply at wordpress.org
Thu Oct 27 21:31:36 UTC 2022


#56923: register_block_core_template_part does WP_Query even on themes that do not
support it
--------------------------+--------------------------
 Reporter:  spacedmonkey  |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  high          |   Milestone:  6.1.1
Component:  Themes        |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  performance
--------------------------+--------------------------
Changes (by sabernhardt):

 * keywords:   => has-patch
 * priority:  normal => high
 * milestone:  Awaiting Review => 6.1.1


Old description:

> register_block_core_template_part functions calls,
> build_template_part_block_variations ->
> build_template_part_block_instance_variations ->
> get_block_templates.
>
> This calls WP_Query and gets ALL posts of post type `wp_template_part`.
> This happens on classic themes that do not even support theme parts.

New description:

 `register_block_core_template_part` functions calls,
 `build_template_part_block_variations` ->
 `build_template_part_block_instance_variations` ->
 `get_block_templates`.

 This calls `WP_Query` and gets ALL posts of post type `wp_template_part`.
 This happens on classic themes that do not even support theme parts.

--

Comment:

 Someone from the release squad could move this to the 6.1 milestone, but I
 can put in the minor.

 Adding that condition removes the extra query from Twenty Seventeen.

 The `build_template_part_block_instance_variations()` function was
 introduced in r54257.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56923#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list