Index: src/wp-includes/option.php
===================================================================
--- src/wp-includes/option.php	(revision 40473)
+++ src/wp-includes/option.php	(working copy)
@@ -205,31 +205,24 @@
  *
  * @since 3.0.0
  *
- * @global wpdb $wpdb WordPress database abstraction object.
+ * @see update_networkmeta_cache()
  *
- * @param int $site_id Optional site ID for which to query the options. Defaults to the current site.
+ * @param int $network_id Optional network ID for which to query the options. Defaults to the current site.
  */
-function wp_load_core_site_options( $site_id = null ) {
-	global $wpdb;
+function wp_load_core_site_options( $network_id = null ) {
 
-	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() )
+	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) {
 		return;
+	}
 
-	if ( empty($site_id) )
-		$site_id = $wpdb->siteid;
-
-	$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' );
-
-	$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", $site_id) );
-
-	foreach ( $options as $option ) {
-		$key = $option->meta_key;
-		$cache_key = "{$site_id}:$key";
-		$option->meta_value = maybe_unserialize( $option->meta_value );
+	$network_id = (int) $network_id;
 
-		wp_cache_set( $cache_key, $option->meta_value, 'site-options' );
+	// Fallback to the current network if a network ID is not specified.
+	if ( empty( $network_id ) ) {
+		$network_id = get_current_network_id();
 	}
+
+	update_networkmeta_cache( $network_id );
 }
 
 /**
@@ -1080,8 +1073,10 @@
  * Retrieve a network's option value based on the option name.
  *
  * @since 4.4.0
+ * @since 4.8.0 Modified into wrapper for get_network_meta()
  *
  * @see get_option()
+ * @see get_network_meta()
  *
  * @global wpdb $wpdb
  *
@@ -1091,7 +1086,6 @@
  * @return mixed Value set for the option.
  */
 function get_network_option( $network_id, $option, $default = false ) {
-	global $wpdb;
 
 	if ( $network_id && ! is_numeric( $network_id ) ) {
 		return false;
@@ -1127,55 +1121,30 @@
 		return $pre;
 	}
 
-	// prevent non-existent options from triggering multiple queries
-	$notoptions_key = "$network_id:notoptions";
-	$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
-
-	if ( isset( $notoptions[ $option ] ) ) {
-
-		/**
-		 * Filters a specific default network option.
-		 *
-		 * The dynamic portion of the hook name, `$option`, refers to the option name.
-		 *
-		 * @since 3.4.0
-		 * @since 4.4.0 The `$option` parameter was added.
-		 * @since 4.7.0 The `$network_id` parameter was added.
-		 *
-		 * @param mixed  $default    The value to return if the site option does not exist
-		 *                           in the database.
-		 * @param string $option     Option name.
-		 * @param int    $network_id ID of the network.
-		 */
-		return apply_filters( "default_site_option_{$option}", $default, $option, $network_id );
-	}
+	/**
+	 * Filters a specific default network option.
+	 *
+	 * The dynamic portion of the hook name, `$option`, refers to the option name.
+	 *
+	 * @since 3.4.0
+	 * @since 4.4.0 The `$option` parameter was added.
+	 * @since 4.7.0 The `$network_id` parameter was added.
+	 *
+	 * @param mixed  $default    The value to return if the site option does not exist
+	 *                           in the database.
+	 * @param string $option     Option name.
+	 * @param int    $network_id ID of the network.
+	 */
+	$default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
 
 	if ( ! is_multisite() ) {
-		/** This filter is documented in wp-includes/option.php */
-		$default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
 		$value = get_option( $option, $default );
 	} else {
-		$cache_key = "$network_id:$option";
-		$value = wp_cache_get( $cache_key, 'site-options' );
-
-		if ( ! isset( $value ) || false === $value ) {
-			$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
-
-			// Has to be get_row instead of get_var because of funkiness with 0, false, null values
-			if ( is_object( $row ) ) {
-				$value = $row->meta_value;
-				$value = maybe_unserialize( $value );
-				wp_cache_set( $cache_key, $value, 'site-options' );
-			} else {
-				if ( ! is_array( $notoptions ) ) {
-					$notoptions = array();
-				}
-				$notoptions[ $option ] = true;
-				wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
-
-				/** This filter is documented in wp-includes/option.php */
-				$value = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
-			}
+		$meta = get_network_meta( $network_id, $option );
+		if ( is_array( $meta ) && ! empty( $meta ) ) {
+			$value = array_shift( $meta );
+		} else {
+			$value = $default;
 		}
 	}
 
@@ -1202,8 +1171,10 @@
  * Existing options will not be updated.
  *
  * @since 4.4.0
+ * @since 4.8.0 Modified into wrapper for add_network_meta()
  *
  * @see add_option()
+ * @see add_network_meta()
  *
  * @global wpdb $wpdb
  *
@@ -1213,7 +1184,6 @@
  * @return bool False if option was not added and true if option was added.
  */
 function add_network_option( $network_id, $option, $value ) {
-	global $wpdb;
 
 	if ( $network_id && ! is_numeric( $network_id ) ) {
 		return false;
@@ -1244,38 +1214,11 @@
 	 */
 	$value = apply_filters( "pre_add_site_option_{$option}", $value, $option, $network_id );
 
-	$notoptions_key = "$network_id:notoptions";
-
 	if ( ! is_multisite() ) {
 		$result = add_option( $option, $value, '', 'no' );
 	} 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
-		$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
-		if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
-			if ( false !== get_network_option( $network_id, $option, false ) ) {
-				return false;
-			}
-		}
-
-		$value = sanitize_option( $option, $value );
-
-		$serialized_value = maybe_serialize( $value );
-		$result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id'    => $network_id, 'meta_key'   => $option, 'meta_value' => $serialized_value ) );
-
-		if ( ! $result ) {
-			return false;
-		}
-
-		wp_cache_set( $cache_key, $value, 'site-options' );
-
-		// This option exists now
-		$notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // yes, again... we need it to be fresh
-		if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
-			unset( $notoptions[ $option ] );
-			wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
-		}
+		$value  = sanitize_option( $option, $value );
+		$result = add_network_meta( $network_id, $option, $value, true );
 	}
 
 	if ( $result ) {
@@ -1317,8 +1260,10 @@
  * Removes a network option by name.
  *
  * @since 4.4.0
+ * @since 4.8.0 Modified into wrapper for delete_network_meta()
  *
  * @see delete_option()
+ * @see delete_network_meta()
  *
  * @global wpdb $wpdb
  *
@@ -1327,7 +1272,6 @@
  * @return bool True, if succeed. False, if failure.
  */
 function delete_network_option( $network_id, $option ) {
-	global $wpdb;
 
 	if ( $network_id && ! is_numeric( $network_id ) ) {
 		return false;
@@ -1357,14 +1301,7 @@
 	if ( ! is_multisite() ) {
 		$result = delete_option( $option );
 	} else {
-		$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
-		if ( is_null( $row ) || ! $row->meta_id ) {
-			return false;
-		}
-		$cache_key = "$network_id:$option";
-		wp_cache_delete( $cache_key, 'site-options' );
-
-		$result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $network_id ) );
+		$result = delete_network_meta( $network_id, $option );
 	}
 
 	if ( $result ) {
@@ -1404,8 +1341,10 @@
  * Update the value of a network option that was already added.
  *
  * @since 4.4.0
+ * @since 4.8.0 Modified into wrapper for update_network_meta()
  *
  * @see update_option()
+ * @see update_network_meta()
  *
  * @global wpdb $wpdb
  *
@@ -1415,7 +1354,6 @@
  * @return bool False if value was not updated and true if value was updated.
  */
 function update_network_option( $network_id, $option, $value ) {
-	global $wpdb;
 
 	if ( $network_id && ! is_numeric( $network_id ) ) {
 		return false;
@@ -1449,33 +1387,15 @@
 	 */
 	$value = apply_filters( "pre_update_site_option_{$option}", $value, $old_value, $option, $network_id );
 
-	if ( $value === $old_value ) {
-		return false;
-	}
-
 	if ( false === $old_value ) {
 		return add_network_option( $network_id, $option, $value );
 	}
 
-	$notoptions_key = "$network_id:notoptions";
-	$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
-	if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
-		unset( $notoptions[ $option ] );
-		wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
-	}
-
 	if ( ! is_multisite() ) {
 		$result = update_option( $option, $value, 'no' );
 	} else {
-		$value = sanitize_option( $option, $value );
-
-		$serialized_value = maybe_serialize( $value );
-		$result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $serialized_value ), array( 'site_id' => $network_id, 'meta_key' => $option ) );
-
-		if ( $result ) {
-			$cache_key = "$network_id:$option";
-			wp_cache_set( $cache_key, $value, 'site-options' );
-		}
+		$value  = sanitize_option( $option, $value );
+		$result = update_network_meta( $network_id, $option, $value, $old_value );
 	}
 
 	if ( $result ) {
Index: tests/phpunit/tests/option/multisite.php
===================================================================
--- tests/phpunit/tests/option/multisite.php	(revision 40473)
+++ tests/phpunit/tests/option/multisite.php	(working copy)
@@ -144,25 +144,6 @@
 		//$this->assertFalse( get_option( $key2 ) ); // check get_option()
 	}
 
-	/**
-	 * @group multisite
-	 */
-	function test_site_notoptions() {
-		global $wpdb;
-		$notoptions_key = "{$wpdb->siteid}:notoptions";
-
-		$_notoptions = wp_cache_get( 'notoptions', 'site-options' );
-		$this->assertEmpty( $_notoptions );
-		$_notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
-		$this->assertEmpty( $_notoptions1 );
-
-		get_site_option( 'burrito' );
-
-		$notoptions = wp_cache_get( 'notoptions', 'site-options' );
-		$this->assertEmpty( $notoptions );
-		$notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
-		$this->assertNotEmpty( $notoptions1 );
-	}
 
 	function test_users_can_register_signup_filter() {
 
