rebase on oct-10-2023
This commit is contained in:
@@ -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 ) );
|
||||
|
||||
@@ -653,8 +664,10 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
|
||||
|
||||
$value = sanitize_option( $option, $value );
|
||||
|
||||
// Make sure the option doesn't already exist.
|
||||
// We can check the 'notoptions' cache before we ask for a DB query.
|
||||
/*
|
||||
* Make sure the option doesn't already exist.
|
||||
* We can check the 'notoptions' cache before we ask for a DB query.
|
||||
*/
|
||||
$notoptions = wp_cache_get( 'notoptions', 'options' );
|
||||
|
||||
if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
|
||||
@@ -727,7 +740,7 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes option by name. Prevents removal of protected WordPress options.
|
||||
* Removes an option by name. Prevents removal of protected WordPress options.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
@@ -987,8 +1000,10 @@ function set_transient( $transient, $value, $expiration = 0 ) {
|
||||
}
|
||||
$result = add_option( $transient_option, $value, '', $autoload );
|
||||
} else {
|
||||
// If expiration is requested, but the transient has no timeout option,
|
||||
// delete, then re-create transient rather than update.
|
||||
/*
|
||||
* If expiration is requested, but the transient has no timeout option,
|
||||
* delete, then re-create transient rather than update.
|
||||
*/
|
||||
$update = true;
|
||||
|
||||
if ( $expiration ) {
|
||||
@@ -1370,7 +1385,7 @@ function add_site_option( $option, $value ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a option by name for the current network.
|
||||
* Removes an option by name for the current network.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 4.4.0 Modified into wrapper for delete_network_option()
|
||||
@@ -1587,8 +1602,10 @@ function add_network_option( $network_id, $option, $value ) {
|
||||
} else {
|
||||
$cache_key = "$network_id:$option";
|
||||
|
||||
// Make sure the option doesn't already exist.
|
||||
// We can check the 'notoptions' cache before we ask for a DB query.
|
||||
/*
|
||||
* Make sure the option doesn't already exist.
|
||||
* We can check the 'notoptions' cache before we ask for a DB query.
|
||||
*/
|
||||
$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
|
||||
|
||||
if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
|
||||
|
||||
Reference in New Issue
Block a user