While attempting to write a unit test to confirm that caching added to wp_add_global_styles_for_blocks() would get cleared if user data changed (as reported in https://github.com/WordPress/gutenberg/issues/63467), I noticed that when a wp_global_styles Post is created directly by the WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_wp_global_styles() method, subsequent calls to the same method would not return the post that was created:
$theme = wp_get_theme();
// First call.
WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_wp_global_styles( $theme, true );
// Second call.
WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_wp_global_styles( $theme );
I would have expected the second call to return the post that was created by the first, but instead an empty array is returned because the internal tax query causes the post to not be returned.
Description
While attempting to write a unit test to confirm that caching added to wp_add_global_styles_for_blocks() would get cleared if user data changed (as reported in https://github.com/WordPress/gutenberg/issues/63467), I noticed that when a
wp_global_styles
Post is created directly by theWP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_wp_global_styles()
method, subsequent calls to the same method would not return the post that was created:I would have expected the second call to return the post that was created by the first, but instead an empty array is returned because the internal tax query causes the post to not be returned.
Is this behaving as expected?
Step-by-step reproduction instructions
I've opened https://github.com/WordPress/gutenberg/pull/63721 which adds a PHPUnit test that demonstrates the bug.
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.