Multisite: Ensure the {$network_id}:notoptions array is set in cache in get_network_option().

Prior to this change, the `{$network_id}:notoptions` cache would only be fetched, but not set, unless the actual database lookup would be unsuccessful. This enhancement slightly improves performance by preventing unnecessary external object cache lookups if one is used.

Fixes #43506.

Built from https://develop.svn.wordpress.org/trunk@42833


git-svn-id: http://core.svn.wordpress.org/trunk@42663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz 2018-03-13 15:37:33 +00:00
parent ed1df81bba
commit 57fd97017e
2 changed files with 7 additions and 2 deletions

View File

@ -1247,7 +1247,7 @@ function get_network_option( $network_id, $option, $default = false ) {
$notoptions_key = "$network_id:notoptions";
$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
if ( isset( $notoptions[ $option ] ) ) {
if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
/**
* Filters a specific default network option.
@ -1295,6 +1295,11 @@ function get_network_option( $network_id, $option, $default = false ) {
}
}
if ( ! is_array( $notoptions ) ) {
$notoptions = array();
wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
}
/**
* Filters the value of an existing network option.
*

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-42832';
$wp_version = '5.0-alpha-42833';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.