diff --git src/wp-includes/class-wp-network-query.php src/wp-includes/class-wp-network-query.php
index 9a0f97a912..e13bf25e40 100644
--- src/wp-includes/class-wp-network-query.php
+++ src/wp-includes/class-wp-network-query.php
@@ -213,35 +213,38 @@ class WP_Network_Query {
 		 */
 		$network_ids = apply_filters_ref_array( 'networks_pre_query', array( $network_ids, &$this ) );
 
-		if ( null === $network_ids ) {
+		if ( null !== $network_ids ) {
+			$this->networks = $network_ids;
 
-			// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
-			$_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
+			return $this->networks;
+		}
 
-			// Ignore the $fields argument as the queried result will be the same regardless.
-			unset( $_args['fields'] );
+		// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
+		$_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
 
-			$key          = md5( serialize( $_args ) );
-			$last_changed = wp_cache_get_last_changed( 'networks' );
+		// Ignore the $fields argument as the queried result will be the same regardless.
+		unset( $_args['fields'] );
 
-			$cache_key   = "get_network_ids:$key:$last_changed";
-			$cache_value = wp_cache_get( $cache_key, 'networks' );
+		$key          = md5( serialize( $_args ) );
+		$last_changed = wp_cache_get_last_changed( 'networks' );
 
-			if ( false === $cache_value ) {
-				$network_ids = $this->get_network_ids();
-				if ( $network_ids ) {
-					$this->set_found_networks();
-				}
+		$cache_key   = "get_network_ids:$key:$last_changed";
+		$cache_value = wp_cache_get( $cache_key, 'networks' );
 
-				$cache_value = array(
-					'network_ids'    => $network_ids,
-					'found_networks' => $this->found_networks,
-				);
-				wp_cache_add( $cache_key, $cache_value, 'networks' );
-			} else {
-				$network_ids          = $cache_value['network_ids'];
-				$this->found_networks = $cache_value['found_networks'];
+		if ( false === $cache_value ) {
+			$network_ids = $this->get_network_ids();
+			if ( $network_ids ) {
+				$this->set_found_networks();
 			}
+
+			$cache_value = array(
+				'network_ids'    => $network_ids,
+				'found_networks' => $this->found_networks,
+			);
+			wp_cache_add( $cache_key, $cache_value, 'networks' );
+		} else {
+			$network_ids          = $cache_value['network_ids'];
+			$this->found_networks = $cache_value['found_networks'];
 		}
 
 		if ( $this->found_networks && $this->query_vars['number'] ) {
diff --git src/wp-includes/class-wp-site-query.php src/wp-includes/class-wp-site-query.php
index ae91c8269e..a42bf1f7c3 100644
--- src/wp-includes/class-wp-site-query.php
+++ src/wp-includes/class-wp-site-query.php
@@ -304,35 +304,38 @@ class WP_Site_Query {
 		 */
 		$site_ids = apply_filters_ref_array( 'sites_pre_query', array( $site_ids, &$this ) );
 
-		if ( null === $site_ids ) {
+		if ( null !== $site_ids ) {
+			$this->sites = $site_ids;
 
-			// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
-			$_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
+			return $this->sites;
+		}
 
-			// Ignore the $fields argument as the queried result will be the same regardless.
-			unset( $_args['fields'] );
+		// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
+		$_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) );
 
-			$key          = md5( serialize( $_args ) );
-			$last_changed = wp_cache_get_last_changed( 'sites' );
+		// Ignore the $fields argument as the queried result will be the same regardless.
+		unset( $_args['fields'] );
 
-			$cache_key   = "get_sites:$key:$last_changed";
-			$cache_value = wp_cache_get( $cache_key, 'sites' );
+		$key          = md5( serialize( $_args ) );
+		$last_changed = wp_cache_get_last_changed( 'sites' );
 
-			if ( false === $cache_value ) {
-				$site_ids = $this->get_site_ids();
-				if ( $site_ids ) {
-					$this->set_found_sites();
-				}
+		$cache_key   = "get_sites:$key:$last_changed";
+		$cache_value = wp_cache_get( $cache_key, 'sites' );
 
-				$cache_value = array(
-					'site_ids'    => $site_ids,
-					'found_sites' => $this->found_sites,
-				);
-				wp_cache_add( $cache_key, $cache_value, 'sites' );
-			} else {
-				$site_ids          = $cache_value['site_ids'];
-				$this->found_sites = $cache_value['found_sites'];
+		if ( false === $cache_value ) {
+			$site_ids = $this->get_site_ids();
+			if ( $site_ids ) {
+				$this->set_found_sites();
 			}
+
+			$cache_value = array(
+				'site_ids'    => $site_ids,
+				'found_sites' => $this->found_sites,
+			);
+			wp_cache_add( $cache_key, $cache_value, 'sites' );
+		} else {
+			$site_ids          = $cache_value['site_ids'];
+			$this->found_sites = $cache_value['found_sites'];
 		}
 
 		if ( $this->found_sites && $this->query_vars['number'] ) {
diff --git tests/phpunit/tests/multisite/networkQuery.php tests/phpunit/tests/multisite/networkQuery.php
index 0b48fdc8d5..8953012386 100644
--- tests/phpunit/tests/multisite/networkQuery.php
+++ tests/phpunit/tests/multisite/networkQuery.php
@@ -525,6 +525,7 @@ if ( is_multisite() ) :
 
 		/**
 		 * @ticket 45749
+		 * @ticket 47599
 		 */
 		public function test_networks_pre_query_filter_should_bypass_database_query() {
 			global $wpdb;
@@ -534,11 +535,7 @@ if ( is_multisite() ) :
 			$num_queries = $wpdb->num_queries;
 
 			$q       = new WP_Network_Query();
-			$results = $q->query(
-				array(
-					'fields' => 'ids',
-				)
-			);
+			$results = $q->query( array() );
 
 			remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
 
diff --git tests/phpunit/tests/multisite/siteQuery.php tests/phpunit/tests/multisite/siteQuery.php
index c17f977932..e368642675 100644
--- tests/phpunit/tests/multisite/siteQuery.php
+++ tests/phpunit/tests/multisite/siteQuery.php
@@ -914,6 +914,7 @@ if ( is_multisite() ) :
 
 		/**
 		 * @ticket 45749
+		 * @ticket 47599
 		 */
 		public function test_sites_pre_query_filter_should_bypass_database_query() {
 			global $wpdb;
@@ -923,11 +924,7 @@ if ( is_multisite() ) :
 			$num_queries = $wpdb->num_queries;
 
 			$q       = new WP_Site_Query();
-			$results = $q->query(
-				array(
-					'fields' => 'ids',
-				)
-			);
+			$results = $q->query( array() );
 
 			remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
 
