From 372770980f626feb3aef115b314a723393fb6476 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Fri, 22 Sep 2023 11:57:50 -0500 Subject: [PATCH] Apply PR feedback --- src/wp-includes/class-wp-theme-json-resolver.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index d5bcbd0b397f4..215b6b764e053 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -61,6 +61,7 @@ class WP_Theme_JSON_Resolver { * Container to cache theme support data. * * @since n.e.x.t + * @var array */ protected static $theme_support_data = null; @@ -627,7 +628,8 @@ public static function get_merged_data( $origin = 'custom' ) { if ( null !== static::$merged[ $origin ] && static::has_same_registered_blocks( $cache_map[ $origin ] ) - && static::get_theme_supports_data() === static::$theme_support_data + // Ensure theme supports data is fresh before returning cached data for theme and custom origins. + && ( ! in_array( $origin, array( 'theme', 'custom' ), true ) || static::get_theme_supports_data() === static::$theme_support_data ) ) { return static::$merged[ $origin ]; } @@ -636,17 +638,25 @@ public static function get_merged_data( $origin = 'custom' ) { $result->merge( static::get_core_data() ); if ( 'default' === $origin ) { $result->set_spacing_sizes(); + + static::$merged[ $origin ] = $result; + return $result; } $result->merge( static::get_block_data() ); if ( 'blocks' === $origin ) { + static::$merged[ $origin ] = $result; + return $result; } $result->merge( static::get_theme_data() ); if ( 'theme' === $origin ) { $result->set_spacing_sizes(); + + static::$merged[ $origin ] = $result; + return $result; }