[wp-trac] [WordPress Trac] #62126: Cache duplicate calls to WP_Theme_JSON::sanitize
WordPress Trac
noreply at wordpress.org
Fri Sep 19 18:14:41 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 needs-refresh has-unit- | Focuses:
tests | performance
-------------------------------------------------+-------------------------
Comment (by westonruter):
Given the original logging code in the description added to the beginning
of `sanitize`, I get the following result:
{{{
[19-Sep-2025 18:10:13 UTC] Array
(
[5a711bfeb4c4d9cd4e6b419bf8d8e285] => 2
[b3279a35e434aae0648de957b531454c] => 2
[b8ef9e6b73ffc94a960b6685441def19] => 2
[4d834e3e1efa8331ea6c9114ad5ea7f8] => 2
[901119a5052414a7f95cea1b62cd6ae0] => 2
[d5f4929e5ec13d3ad17377a50fab796b] => 2
[cad6ab868772320aae2e4a13462653e5] => 2
[fd6cec6288d517badd25cb3ed0cbbdbd] => 2
[ff2793c30902232220d2e9d1e10bdba1] => 2
[7f54185488bb2dde2b00131a529c1e43] => 2
[c5ed022349e4a64a02171deb00a3d988] => 5
[3ada4d1ae675481f9d5ac28d0e39287b] => 2
[7aef88bb839b090be13dc01ab67a52e1] => 2
[a277ebc729ba3b9e28c492d103043a2e] => 5
[9d885aa254f4281c1bd719d1f80348d0] => 2
)
}}}
However, when I change the `$input_key` to include the other arguments
passed to `sanitize()`:
{{{#!php
<?php
$input_key = md5( serialize( compact( 'input', 'valid_block_names',
'valid_element_names', 'valid_variations' ) ) );
}}}
I get the following:
{{{
[19-Sep-2025 18:10:52 UTC] Array
(
[d912ce88a285afebdff6b2433de9b47a] => 1
[18cdd5519815f9a4b3479562083fad6b] => 1
[73ebc5d622a626b682728b2f5cd20236] => 1
[9facf692dea88de9ecbc7cf333ab8609] => 1
[93b2da2e8b6242fa3fe8cf772cf1dc5d] => 1
[67dae318fde353ce133c13bd8f0d328a] => 1
[b67dd5d6421ace6c4bd65218e5a11b16] => 1
[b1df13f38cfb9b2bf1d3ad4ac8279964] => 1
[4692b9d28608b3ac26a5482db312cde7] => 1
[02a3f2f17a1780465f8490487f58cc7f] => 2
[18973091d16f173235139a0dce8bd49a] => 1
[5bafb6bca8a117cb831c9765a76c28ab] => 1
[f5b2260df6ba91ddc4313d874f507423] => 1
[047e1ffc5eb96a869f2c75c267fdac72] => 1
[50083737ecefeb004c1e438debea9b83] => 1
[84b11ebf68e083d91ffcdc7ee71fe309] => 1
[882d4890a68c5ae3c0b01495683a5860] => 1
[54e5e245a371e0d8d3eb4d3307d86fcb] => 1
[44ea0804e97f7ad261cbd1dd313550fe] => 1
[7169040703ede04b1013bcbb5e25420b] => 5
[6a5f1b88747798ff256098346e3aabfd] => 2
[0529abcf2315035f43d401e128efdaa2] => 2
[b6116437f73bc028d5a9842a301d4faa] => 5
[84002271b40977da4ef03b55b600898c] => 2
)
}}}
So you can see the HIT rate is much reduced.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62126#comment:44>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list