Skip to content

Fix performance issue#3609

Closed
spacedmonkey wants to merge 5 commits intoWordPress:trunkfrom
spacedmonkey:fix/57077
Closed

Fix performance issue#3609
spacedmonkey wants to merge 5 commits intoWordPress:trunkfrom
spacedmonkey:fix/57077

Conversation

@spacedmonkey
Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/57077


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

}

$theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_custom_templates();
$theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@felixarntz @desrosj @peterwilsoncc This work, because, supports are not needed here. You just need a WP_Theme_Json object. Adding these params, means that it hits a cache that it would not before. This function is called 300+ times a page load, there some serious savings here.

@spacedmonkey
Copy link
Copy Markdown
Member Author

Closing in favour of #3624

@SergeyBiryukov
Copy link
Copy Markdown
Member

SergeyBiryukov commented Dec 13, 2022

Though I'm not super familiar with this code, the suggested change looks like an easy win.

I was wondering about _add_block_template_part_area_info(). It has a similar line, does it need the same change?

Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@spacedmonkey Looks great, only pending @SergeyBiryukov's question.

function _add_block_template_part_area_info( $template_info ) {
if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
$theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_template_parts();
$theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_template_parts();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@SergeyBiryukov This works well!

@spacedmonkey
Copy link
Copy Markdown
Member Author

@spacedmonkey Looks great, only pending @SergeyBiryukov's question.

@felixarntz Actioned the feedback.

@spacedmonkey
Copy link
Copy Markdown
Member Author

Committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants