Make WordPress Core

Changeset 59338


Ignore:
Timestamp:
11/04/2024 02:32:25 AM (5 months ago)
Author:
ramonopoly
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json-resolver.php

    r58797 r59338  
    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 ) {
     
    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
Note: See TracChangeset for help on using the changeset viewer.