Index: src/wp-includes/ms-functions.php
===================================================================
--- src/wp-includes/ms-functions.php	(revision 40483)
+++ src/wp-includes/ms-functions.php	(working copy)
@@ -2329,21 +2329,25 @@
  * Update the network-wide site count.
  *
  * @since 3.7.0
+ * @since 4.8.0 The $network_id parameter has been added.
  *
- * @global wpdb $wpdb WordPress database abstraction object.
+ * @param int|null $network_id ID of the network. Default is the current network.
  */
-function wp_update_network_site_counts() {
-	global $wpdb;
+function wp_update_network_site_counts( $network_id = null ) {
+	$network_id = (int) $network_id;
+	if ( ! $network_id ) {
+		$network_id = get_current_network_id();
+	}
 
 	$count = get_sites( array(
-		'network_id' => $wpdb->siteid,
+		'network_id' => $network_id,
 		'spam'       => 0,
 		'deleted'    => 0,
 		'archived'   => 0,
 		'count'      => true,
 	) );
 
-	update_site_option( 'blog_count', $count );
+	update_network_option( $network_id, 'blog_count', $count );
 }
 
 /**
Index: tests/phpunit/tests/multisite/network.php
===================================================================
--- tests/phpunit/tests/multisite/network.php	(revision 40483)
+++ tests/phpunit/tests/multisite/network.php	(working copy)
@@ -376,6 +376,38 @@
 		$dashboard_blog = get_dashboard_blog();
 		$this->assertEquals( $blog_id, $dashboard_blog->blog_id );
 	}
+
+	/**
+	 * @ticket 37528
+	 */
+	function test_wp_update_network_site_counts() {
+		update_network_option( null, 'blog_count', 40 );
+
+		$expected = get_sites( array(
+			'network_id' => get_current_network_id(),
+			'spam'       => 0,
+			'deleted'    => 0,
+			'archived'   => 0,
+			'count'      => true,
+		) );
+
+		wp_update_network_site_counts();
+
+		$result = get_blog_count();
+		$this->assertEquals( $expected, $result );
+	}
+
+	/**
+	 * @ticket 37528
+	 */
+	function test_wp_update_network_site_counts_on_different_network() {
+		update_network_option( self::$different_network_id, 'blog_count', 40 );
+
+		wp_update_network_site_counts( self::$different_network_id );
+
+		$result = get_blog_count( self::$different_network_id );
+		$this->assertEquals( 3, $result );
+	}
 }
 
 endif;
