Index: src/wp-includes/class-wp-site-query.php
===================================================================
--- src/wp-includes/class-wp-site-query.php	(revision 37746)
+++ src/wp-includes/class-wp-site-query.php	(working copy)
@@ -256,12 +256,21 @@
 			$last_changed = microtime();
 			wp_cache_set( 'last_changed', $last_changed, 'sites' );
 		}
-		$cache_key = "get_site_ids:$key:$last_changed";
-
-		$site_ids = wp_cache_get( $cache_key, 'sites' );
-		if ( false === $site_ids ) {
+		$cache_key   = "get_sites:$key:$last_changed";
+		$cache_value = wp_cache_get( $cache_key, 'sites' );
+		if ( false === $cache_value ) {
 			$site_ids = $this->get_site_ids();
-			wp_cache_add( $cache_key, $site_ids, 'sites' );
+			$this->set_found_sites();
+			$cache_value = array(
+				'site_ids'      => $site_ids,
+				'found_sites'   => $this->found_sites,
+				'max_num_pages' => $this->max_num_pages
+			);
+			wp_cache_add( $cache_key, $cache_value, 'sites' );
+		} else {
+			$site_ids            = $cache_value['site_ids'];
+			$this->found_sites   = $cache_value['found_sites'];
+			$this->max_num_pages = $cache_value['max_num_pages'];
 		}
 
 		// If querying for a count only, there's nothing more to do.
@@ -274,21 +283,6 @@
 
 		$this->site_count = count( $this->sites );
 
-		if ( $site_ids && $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
-			/**
-			 * Filters the query used to retrieve found site count.
-			 *
-			 * @since 4.6.0
-			 *
-			 * @param string        $found_sites_query SQL query. Default 'SELECT FOUND_ROWS()'.
-			 * @param WP_Site_Query $site_query        The `WP_Site_Query` instance.
-			 */
-			$found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this );
-
-			$this->found_sites = (int) $wpdb->get_var( $found_sites_query );
-			$this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] );
-		}
-
 		if ( 'ids' == $this->query_vars['fields'] ) {
 			$this->sites = $site_ids;
 
@@ -572,6 +566,35 @@
 	}
 
 	/**
+	 * Set up the amount of found sites and the number of pages (if limit clause was used)
+	 * for the current query.
+	 *
+	 * @since 4.6.0
+	 * @access private
+	 *
+	 * @global wpdb $wpdb WordPress database abstraction object.
+	 *
+	 */
+	private function set_found_sites() {
+		global $wpdb;
+
+		if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
+			/**
+			 * Filters the query used to retrieve found site count.
+			 *
+			 * @since 4.6.0
+			 *
+			 * @param string $found_sites_query SQL query. Default 'SELECT FOUND_ROWS()'.
+			 * @param WP_Site_Query $site_query The `WP_Site_Query` instance (passed by reference).
+			 */
+			$found_sites_query = apply_filters_ref_array( 'found_sites_query', array( 'SELECT FOUND_ROWS()', &$this ) );
+
+			$this->found_sites   = (int) $wpdb->get_var( $found_sites_query );
+			$this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] );
+		}
+	}
+
+	/**
 	 * Used internally to generate an SQL string for searching across multiple columns.
 	 *
 	 * @since 4.6.0
