Skip to content

Disable post meta/term cache updating in WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles() #45978

@ocean90

Description

@ocean90

Description

Initially started in WordPress/wordpress-develop#3655.

The method currently returns a full WP_Post array while later only the ID and post_content fields are used. That's causing a lot of unnecessary overhead.

To fix this the WP_Query should be updated to disable update_post_meta_cache and update_post_term_cache. Also, any get_post( $x, ARRAY_A ); calls should be changed to just get_post( $x ) so that WP_Post::to_array() isn't called, preventing post meta lookups. Then we can create a custom array that only includes the two fields ID and post_content as proposed by @spacedmonkey.

Step-by-step reproduction instructions

See code in https://github.com/WordPress/wordpress-develop/blob/95d11878b0d3ed89c05ae894754374620ffae1bd/src/wp-includes/class-wp-theme-json-resolver.php#L411.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Type] PerformanceRelated to performance efforts

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions