diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index c8bc92e44c..57ffe69054 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -1068,6 +1068,16 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam update_user_meta( $site_user->ID, 'source_domain', $domain ); update_user_meta( $site_user->ID, 'primary_blog', $current_site->blog_id ); + // Unable to use update_network_option() while populating the network. + $wpdb->insert( + $wpdb->sitemeta, + array( + 'site_id' => $network_id, + 'meta_key' => 'main_site', + 'meta_value' => $current_site->blog_id, + ) + ); + if ( $subdomain_install ) { $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); } else { diff --git a/wp-includes/class-wp-network.php b/wp-includes/class-wp-network.php index 75b407e541..fd92c5ba70 100644 --- a/wp-includes/class-wp-network.php +++ b/wp-includes/class-wp-network.php @@ -255,9 +255,8 @@ class WP_Network { if ( $site->domain === $this->domain && $site->path === $this->path ) { $main_site_id = (int) $site->id; } else { - $cache_key = 'network:' . $this->id . ':main_site'; - $main_site_id = wp_cache_get( $cache_key, 'site-options' ); + $main_site_id = get_network_option( $this->id, 'main_site' ); if ( false === $main_site_id ) { $_sites = get_sites( array( @@ -270,7 +269,7 @@ class WP_Network { ); $main_site_id = ! empty( $_sites ) ? array_shift( $_sites ) : 0; - wp_cache_add( $cache_key, $main_site_id, 'site-options' ); + update_network_option( $this->id, 'main_site', $main_site_id ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index cc39678976..c4e5912422 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-54255'; +$wp_version = '6.1-alpha-54256'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.