Skip to content

Commit

Permalink
Performance: Disable lazy term meta loading render_block_core_templat…
Browse files Browse the repository at this point in the history
…e_part. (#48000)

* Disable lazy term meta loading render_block_core_template_part.

* Add comment.
  • Loading branch information
spacedmonkey authored Feb 23, 2023
1 parent 09df1a4 commit 80cd581
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.1/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function gutenberg_get_block_templates( $query = array(), $template_type = 'wp_t
'post_type' => $template_type,
'posts_per_page' => -1,
'no_found_rows' => true,
'lazy_load_term_meta' => false,
'lazy_load_term_meta' => false, // Do not lazy load term meta, as template post types only have one term.
'tax_query' => array(
array(
'taxonomy' => 'wp_theme',
Expand Down
13 changes: 7 additions & 6 deletions packages/block-library/src/template-part/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ function render_block_core_template_part( $attributes ) {
$template_part_id = $attributes['theme'] . '//' . $attributes['slug'];
$template_part_query = new WP_Query(
array(
'post_type' => 'wp_template_part',
'post_status' => 'publish',
'post_name__in' => array( $attributes['slug'] ),
'tax_query' => array(
'post_type' => 'wp_template_part',
'post_status' => 'publish',
'post_name__in' => array( $attributes['slug'] ),
'tax_query' => array(
array(
'taxonomy' => 'wp_theme',
'field' => 'name',
'terms' => $attributes['theme'],
),
),
'posts_per_page' => 1,
'no_found_rows' => true,
'posts_per_page' => 1,
'no_found_rows' => true,
'lazy_load_term_meta' => false, // Do not lazy load term meta, as template parts only have one term.
)
);
$template_part_post = $template_part_query->have_posts() ? $template_part_query->next_post() : null;
Expand Down

1 comment on commit 80cd581

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 80cd581.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4255178232
📝 Reported issues:

Please sign in to comment.