mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 07:37:44 +02:00
Themes: Revert caching from r55086.
Calls to `wp-admin/load-styles.php` do not include the loading of `wp_cache_*()` functions. With [55086], this caused a fatal error: {{{ Fatal error: Uncaught Error: Call to undefined function wp_cache_get() in /wp-includes/global-styles-and-settings.php on line 285 }}} In some production and local environments running `trunk`, the admin area looked broken as the styling was not loaded as there were no HTTP requests. This commit reverts the caching from [55086] to restore sites running `trunk` until a solution is found. Follow-up to [55086]. Props Otto42, dmsnell, costdev. See #56975. Built from https://develop.svn.wordpress.org/trunk@55092 git-svn-id: http://core.svn.wordpress.org/trunk@54625 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8c310381f2
commit
18b551b84d
@ -264,42 +264,6 @@ function wp_add_global_styles_for_blocks() {
|
|||||||
* @return bool Returns true if theme or its parent has a theme.json file, false otherwise.
|
* @return bool Returns true if theme or its parent has a theme.json file, false otherwise.
|
||||||
*/
|
*/
|
||||||
function wp_theme_has_theme_json() {
|
function wp_theme_has_theme_json() {
|
||||||
/*
|
|
||||||
* By using the 'theme_json' group, this data is marked to be non-persistent across requests.
|
|
||||||
* @see `wp_cache_add_non_persistent_groups()`.
|
|
||||||
*
|
|
||||||
* The rationale for this is to make sure derived data from theme.json
|
|
||||||
* is always fresh from the potential modifications done via hooks
|
|
||||||
* that can use dynamic data (modify the stylesheet depending on some option,
|
|
||||||
* settings depending on user permissions, etc.).
|
|
||||||
* For some of the existing hooks to modify theme.json behavior:
|
|
||||||
* @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/
|
|
||||||
*
|
|
||||||
* A different alternative considered was to invalidate the cache upon certain
|
|
||||||
* events such as options add/update/delete, user meta, etc.
|
|
||||||
* It was judged not enough, hence this approach.
|
|
||||||
* @see https://github.com/WordPress/gutenberg/pull/45372
|
|
||||||
*/
|
|
||||||
$cache_group = 'theme_json';
|
|
||||||
$cache_key = 'wp_theme_has_theme_json';
|
|
||||||
$theme_has_support = wp_cache_get( $cache_key, $cache_group );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* $theme_has_support is stored as an int in the cache.
|
|
||||||
*
|
|
||||||
* The reason not to store it as a boolean is to avoid working
|
|
||||||
* with the $found parameter which apparently had some issues in some implementations
|
|
||||||
* @see https://developer.wordpress.org/reference/functions/wp_cache_get/
|
|
||||||
*
|
|
||||||
* Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme
|
|
||||||
* developer's workflow.
|
|
||||||
*
|
|
||||||
* @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
|
|
||||||
*/
|
|
||||||
if ( ! WP_DEBUG && is_int( $theme_has_support ) ) {
|
|
||||||
return (bool) $theme_has_support;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Does the theme have its own theme.json?
|
// Does the theme have its own theme.json?
|
||||||
$theme_has_support = is_readable( get_stylesheet_directory() . '/theme.json' );
|
$theme_has_support = is_readable( get_stylesheet_directory() . '/theme.json' );
|
||||||
|
|
||||||
@ -308,11 +272,7 @@ function wp_theme_has_theme_json() {
|
|||||||
$theme_has_support = is_readable( get_template_directory() . '/theme.json' );
|
$theme_has_support = is_readable( get_template_directory() . '/theme.json' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$theme_has_support = $theme_has_support ? 1 : 0;
|
return $theme_has_support;
|
||||||
|
|
||||||
wp_cache_set( $cache_key, $theme_has_support, $cache_group );
|
|
||||||
|
|
||||||
return (bool) $theme_has_support;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -321,6 +281,5 @@ function wp_theme_has_theme_json() {
|
|||||||
* @since 6.2.0
|
* @since 6.2.0
|
||||||
*/
|
*/
|
||||||
function wp_clean_theme_json_cache() {
|
function wp_clean_theme_json_cache() {
|
||||||
wp_cache_delete( 'wp_theme_has_theme_json', 'theme_json' );
|
|
||||||
WP_Theme_JSON_Resolver::clean_cached_data();
|
WP_Theme_JSON_Resolver::clean_cached_data();
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ function wp_start_object_cache() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
|
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$first_init = false;
|
$first_init = false;
|
||||||
|
@ -575,7 +575,7 @@ function switch_to_blog( $new_blog_id, $deprecated = null ) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
|
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ function restore_current_blog() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
|
wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.2-alpha-55091';
|
$wp_version = '6.2-alpha-55092';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user