Skip to content

Commit b6430c2

Browse files
committed
Theme JSON Resolver: remove theme json merge in resolve_theme_file_uris
This commit affects `WP_Theme_JSON_Resolver::resolve_theme_file_uris()`. When setting resolved URIs in an incoming theme json object, this commit removes the unnecessary call to `WP_Theme_JSON->merge()`. Why? `WP_Theme_JSON_Resolver::resolve_theme_file_uris()` only needs to set values for paths in the raw theme json object. It can then return a new theme object based on the updated JSON source. There's no need for a full and possibly expensive merge. Follow-up to [61588]. Props ramonopoly, aaronrobertshaw, andrewserong. Fixes #62329. git-svn-id: https://develop.svn.wordpress.org/trunk@59338 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 78602b4 commit b6430c2

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/wp-includes/class-wp-theme-json-resolver.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -933,18 +933,14 @@ public static function resolve_theme_file_uris( $theme_json ) {
933933
return $theme_json;
934934
}
935935

936-
$resolved_theme_json_data = array(
937-
'version' => WP_Theme_JSON::LATEST_SCHEMA,
938-
);
936+
$resolved_theme_json_data = $theme_json->get_raw_data();
939937

940938
foreach ( $resolved_urls as $resolved_url ) {
941939
$path = explode( '.', $resolved_url['target'] );
942940
_wp_array_set( $resolved_theme_json_data, $path, $resolved_url['href'] );
943941
}
944942

945-
$theme_json->merge( new WP_Theme_JSON( $resolved_theme_json_data ) );
946-
947-
return $theme_json;
943+
return new WP_Theme_JSON( $resolved_theme_json_data );
948944
}
949945

950946
/**

0 commit comments

Comments
 (0)