Options, Meta APIs: Prime network options in a single cache call using wp_cache_get_multiple.
Tweak the `wp_load_core_site_options` function, to also prime network options using `wp_cache_get_multiple` if persistent object cache is present. Props mukesh27, oglekler, peterwilsoncc, costdev, jeremyfelt, spacedmonkey. Fixes #56913. Built from https://develop.svn.wordpress.org/trunk@56061 git-svn-id: http://core.svn.wordpress.org/trunk@55573 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
aa404f099e
commit
b688be1c8c
|
@ -361,18 +361,19 @@ function wp_load_alloptions( $force_cache = false ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used.
|
||||
* Loads and primes caches of certain often requested network options if is_multisite().
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @since 6.3.0 Also prime caches for network options when persistent object cache is enabled.
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param int $network_id Optional site ID for which to query the options. Defaults to the current site.
|
||||
* @param int $network_id Optional. Network ID of network for which to prime network options cache. Defaults to current network.
|
||||
*/
|
||||
function wp_load_core_site_options( $network_id = null ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) {
|
||||
if ( ! is_multisite() || wp_installing() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -382,6 +383,16 @@ function wp_load_core_site_options( $network_id = null ) {
|
|||
|
||||
$core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
|
||||
|
||||
if ( wp_using_ext_object_cache() ) {
|
||||
$cache_keys = array();
|
||||
foreach ( $core_options as $option ) {
|
||||
$cache_keys[] = "{$network_id}:{$option}";
|
||||
}
|
||||
wp_cache_get_multiple( $cache_keys, 'site-options' );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$core_options_in = "'" . implode( "', '", $core_options ) . "'";
|
||||
$options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $network_id ) );
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.3-alpha-56060';
|
||||
$wp_version = '6.3-alpha-56061';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue