Changeset 54256
- Timestamp:
- 09/20/2022 02:24:08 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/schema.php
r54240 r54256 1069 1069 update_user_meta( $site_user->ID, 'primary_blog', $current_site->blog_id ); 1070 1070 1071 // Unable to use update_network_option() while populating the network. 1072 $wpdb->insert( 1073 $wpdb->sitemeta, 1074 array( 1075 'site_id' => $network_id, 1076 'meta_key' => 'main_site', 1077 'meta_value' => $current_site->blog_id, 1078 ) 1079 ); 1080 1071 1081 if ( $subdomain_install ) { 1072 1082 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); -
trunk/src/wp-includes/class-wp-network.php
r54133 r54256 256 256 $main_site_id = (int) $site->id; 257 257 } else { 258 $cache_key = 'network:' . $this->id . ':main_site'; 259 260 $main_site_id = wp_cache_get( $cache_key, 'site-options' ); 258 259 $main_site_id = get_network_option( $this->id, 'main_site' ); 261 260 if ( false === $main_site_id ) { 262 261 $_sites = get_sites( … … 271 270 $main_site_id = ! empty( $_sites ) ? array_shift( $_sites ) : 0; 272 271 273 wp_cache_add( $cache_key, $main_site_id, 'site-options');272 update_network_option( $this->id, 'main_site', $main_site_id ); 274 273 } 275 274 } -
trunk/tests/phpunit/tests/multisite/getMainSiteId.php
r51860 r54256 90 90 91 91 /** 92 * @ticket 55802 93 */ 94 public function test_get_main_site_id_with_different_network_cache_id() { 95 $this->assertSame( self::$site_ids['wordpress.org/'], get_main_site_id( self::$network_ids['wordpress.org/'] ), 'Main blog id needs to match blog id of wordpress.org/' ); 96 $this->assertSame( self::$site_ids['wordpress.org/'], (int) get_network_option( self::$network_ids['wordpress.org/'], 'main_site' ), 'Network option needs to match blog id of wordpress.org/' ); 97 98 $this->assertSame( 0, get_main_site_id( self::$network_ids['wp.org/'] ), 'Main blog id should not be found' ); 99 $this->assertSame( 0, (int) get_network_option( self::$network_ids['wp.org/'], 'main_site' ), 'Network option should not be found' ); 100 } 101 102 /** 92 103 * @ticket 29684 93 104 */
Note: See TracChangeset
for help on using the changeset viewer.