[wp-trac] [WordPress Trac] #62126: Cache duplicate calls to WP_Theme_JSON::sanitize

WordPress Trac noreply at wordpress.org
Wed Sep 17 17:32:55 UTC 2025


#62126: Cache duplicate calls to WP_Theme_JSON::sanitize
-----------------------------------------+--------------------------
 Reporter:  josephscott                  |       Owner:  pbearne
     Type:  enhancement                  |      Status:  assigned
 Priority:  normal                       |   Milestone:  6.9
Component:  General                      |     Version:  5.8
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:  performance
-----------------------------------------+--------------------------

Comment (by josephscott):

 Trying out https://github.com/WordPress/wordpress-develop/pull/8213 from
 @pbearne I looked at just the time spent in `WP_Theme_JSON::sanitize` with
 SPX.  This was on WP 6.9-alpha-60726 with PHP 8.4.11 on the logged out
 front page of the site.  No other plugins, basically a near fresh WP site.
 Before collecting the data from SPX for each run I loaded the front page
 of the site 5 times, then loaded it one time with SPX enabled.

 - Before: 1.18ms
 - After: 0.803ms

 That 0.377ms is a nearly 32% improvement.  Granted we are talking small
 numbers here, but is a move in the right direction.

 Before this change SPX listed these as the top 5 areas for time:

 - wpdb::_do_query
 - wp-settings.php
 - WP_Theme_JSON::sanitize
 - WP_Theme_JSON_Resolver::get_style_variations
 - WP_Theme_JSON::remove_keys_not_in_schema

 After this change that shifted to:

 - wpdb::_do_query
 - wp-settings.php
 - WP_Theme_JSON_Resolver::get_style_variations
 - WP_Theme_JSON::sanitize
 - WP_Theme_JSON::merge

 Pushing the slowest parts of the system to be a bit faster is a win.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62126#comment:35>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list