#55392 closed defect (bug) (fixed)
Performance improvements to get_user_data_from_wp_global_styles
Reported by: | spacedmonkey | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 5.9 |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests add-to-field-guide |
Focuses: | performance | Cc: |
Description
The get_user_data_from_wp_global_styles
in the WP_Theme_JSON_Resolver
class have a number of performance issues. These include by are not limited to.
The following params should be passing the WP_Query object to increase performance.
'ignore_sticky_posts' => true,
'suppress_filters' => false,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'lazy_load_term_meta' => false,
'no_found_rows' => true,
'suppress_filters' => false,
- Cache invalidation now happens when posts are not updated and not just on an hour.
- Handle if
wp_insert_posts
returns a WP_Error. - Only return ids in query, to make query simplifier.
Attachments (2)
Change History (23)
This ticket was mentioned in PR #2414 on WordPress/wordpress-develop by spacedmonkey.
3 years ago
#1
spacedmonkey commented on PR #2414:
2 years ago
#2
I have added some improved unit tests and tweaked this function so it now caches even more.
CC @oandregal @Mamaduka for a review, as they have worked on this function in the past.
spacedmonkey commented on PR #2414:
2 years ago
#4
I think this is great, but I wonder if this wouldn't be better as a Gutenberg PR instead of a core patch. i fear that if a gutenberg specific resolver class is added in compat merging will be hell.
@draganescu Now that this code lives in core, should PR not be done here? Would this not mean that have to port it over, adding more steps. This process, is not documented and is confusing me to.
draganescu commented on PR #2414:
2 years ago
#5
This process, is not documented and is confusing me to.
This is true! But the code is still being heavily changed so I think to make Gutenberg plugin merges simpler we should not patch core with anything that is related to Gutenberg and can be created as a Gutenberg patch /PR.
#6
@
2 years ago
@spacedmonkey this looks like a solid performance enhancement, bravo! Love to see these wins in theme code as well since it is so potentially impactful.
I see some failing tests under PHP 7.4 on the PR - is there anything else needed before this can land?
#7
@
2 years ago
I have spent a little time on this. This change is still worth merging, as it skipping all the logic in WP_Query takes away some over head.
I will look into why tests are failing and merge.
#10
@
2 years ago
- Owner set to spacedmonkey
- Resolution set to fixed
- Status changed from new to closed
In 54186:
spacedmonkey commented on PR #2414:
2 years ago
#11
Committed into core.
#12
@
2 years ago
- Keywords needs-refresh added
- Resolution fixed deleted
- Status changed from closed to reopened
This ticket was mentioned in PR #3263 on WordPress/wordpress-develop by kebbet.
2 years ago
#13
- Keywords needs-refresh removed
Trac ticket: https://core.trac.wordpress.org/ticket/55392
mukeshpanchal27 commented on PR #3263:
2 years ago
#14
Thanks for flagging the issue.
In core we use similar core reference tickets. There is no specific format for this type of document.
https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php#L331
https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php#L333
https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/blocks/gallery.php#L84
Let's update the message and use period at end.
// Do not make string translatable, see https://core.trac.wordpress.org/ticket/54518.
2 years ago
#15
Thanks for flagging the issue.
In core we use similar core reference tickets. There is no specific format for this type of document.
https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php#L331 https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php#L333 https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/blocks/gallery.php#L84
Let's update the message and use period at end.
// Do not make string translatable, see https://core.trac.wordpress.org/ticket/54518.
Thanks for your review @mukeshpanchal27. The two commits adds a preiod and removes ticket
from the comment.
#16
@
2 years ago
The PR looks good to me and ready for the commit.
@spacedmonkey Can you please review it?
#17
@
2 years ago
@spacedmonkey I can not see the reason why the post_title
was made translatable in [54186]. Could you please review the PR that reverts that particular change?
#19
@
2 years ago
- Resolution set to fixed
- Status changed from reopened to closed
@kebbet @mukesh27
Thanks for the flag. Fixed in [54246].
Trac ticket: https://core.trac.wordpress.org/ticket/55392