-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] PerformanceRelated to performance effortsRelated to performance efforts
Description
Description
We noticed a few performance related issues in big multisite WP site related to the uncached queries used in WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_custom_post_type()
. While there's some caching done at the class level, it'd be good to use object caching to avoid unnecessary SQL queries triggered by the call to wp_get_recent_posts
.
Step-by-step reproduction instructions
Please run the following snippet in a WP install with Gutenberg installed.
Screenshots, screen recording, code snippet
<?php
require __DIR__ . '/wp-load.php';
$__queries = array();
$__func = function( $query ) use ( &$__queries ) {
if ( preg_match( '#post_type = \'wp_global_styles\'#', $query ) ) {
$__queries[] = $query;
}
return $query;
};
add_filter( 'query', $__func );
for ( $i = 0; $i < 10; $i++ ) {
WP_Theme_JSON_Resolver_Gutenberg::get_user_data();
WP_Theme_JSON_Resolver_Gutenberg::clean_cached_data();
}
var_dump($__queries);
Ideally, we should only do the SQL query once.
Environment info
- WordPress 5.8.2
- Gutenberg 11.8.3 (the latest versions are also affected, and also add more similar code in
gutenberg_add_active_global_styles_link
)
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Metadata
Metadata
Assignees
Labels
[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] PerformanceRelated to performance effortsRelated to performance efforts