Changeset 55092
- Timestamp:
- 01/18/2023 09:58:00 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/global-styles-and-settings.php
r55086 r55092 265 265 */ 266 266 function wp_theme_has_theme_json() { 267 /*268 * By using the 'theme_json' group, this data is marked to be non-persistent across requests.269 * @see `wp_cache_add_non_persistent_groups()`.270 *271 * The rationale for this is to make sure derived data from theme.json272 * is always fresh from the potential modifications done via hooks273 * that can use dynamic data (modify the stylesheet depending on some option,274 * settings depending on user permissions, etc.).275 * For some of the existing hooks to modify theme.json behavior:276 * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/277 *278 * A different alternative considered was to invalidate the cache upon certain279 * events such as options add/update/delete, user meta, etc.280 * It was judged not enough, hence this approach.281 * @see https://github.com/WordPress/gutenberg/pull/45372282 */283 $cache_group = 'theme_json';284 $cache_key = 'wp_theme_has_theme_json';285 $theme_has_support = wp_cache_get( $cache_key, $cache_group );286 287 /*288 * $theme_has_support is stored as an int in the cache.289 *290 * The reason not to store it as a boolean is to avoid working291 * with the $found parameter which apparently had some issues in some implementations292 * @see https://developer.wordpress.org/reference/functions/wp_cache_get/293 *294 * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme295 * developer's workflow.296 *297 * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.298 */299 if ( ! WP_DEBUG && is_int( $theme_has_support ) ) {300 return (bool) $theme_has_support;301 }302 303 267 // Does the theme have its own theme.json? 304 268 $theme_has_support = is_readable( get_stylesheet_directory() . '/theme.json' ); … … 309 273 } 310 274 311 $theme_has_support = $theme_has_support ? 1 : 0; 312 313 wp_cache_set( $cache_key, $theme_has_support, $cache_group ); 314 315 return (bool) $theme_has_support; 275 return $theme_has_support; 316 276 } 317 277 … … 322 282 */ 323 283 function wp_clean_theme_json_cache() { 324 wp_cache_delete( 'wp_theme_has_theme_json', 'theme_json' );325 284 WP_Theme_JSON_Resolver::clean_cached_data(); 326 285 } -
trunk/src/wp-includes/load.php
r55086 r55092 754 754 ); 755 755 756 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' , 'theme_json') );756 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 757 757 } 758 758 -
trunk/src/wp-includes/ms-blogs.php
r55086 r55092 576 576 } 577 577 578 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' , 'theme_json') );578 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 579 579 } 580 580 } … … 667 667 } 668 668 669 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' , 'theme_json') );669 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 670 670 } 671 671 } -
trunk/tests/phpunit/includes/abstract-testcase.php
r55086 r55092 402 402 ); 403 403 404 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' , 'theme_json') );404 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 405 405 } 406 406
Note: See TracChangeset
for help on using the changeset viewer.