Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance issue #3609

Closed
wants to merge 5 commits into from
Closed

Conversation

spacedmonkey
Copy link
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.

@@ -351,7 +351,8 @@ function _add_block_template_info( $template_item ) {
return $template_item;
}

$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
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
Member Author

Closing in favour of #3624

@SergeyBiryukov
Copy link
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
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.

@@ -371,7 +372,7 @@ function _add_block_template_info( $template_item ) {
*/
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
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
Member Author

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

@felixarntz Actioned the feedback.

@spacedmonkey
Copy link
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