Ticket #29684: 29684.4.diff
File 29684.4.diff, 2.7 KB (added by , 8 years ago) |
---|
-
src/wp-admin/includes/schema.php
1059 1059 $current_site->site_name = ucfirst( $domain ); 1060 1060 $wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) ); 1061 1061 $current_site->blog_id = $blog_id = $wpdb->insert_id; 1062 add_network_option( $current_site->id, 'main_site', $current_site->blog_id ); 1062 1063 update_user_meta( $site_user->ID, 'source_domain', $domain ); 1063 1064 update_user_meta( $site_user->ID, 'primary_blog', $blog_id ); 1064 1065 -
src/wp-includes/class-wp-network.php
157 157 case 'id': 158 158 return (int) $this->id; 159 159 case 'blog_id': 160 $this->get_blog_id(); 160 161 return $this->blog_id; 161 162 case 'site_id': 163 $this->get_blog_id(); 162 164 return (int) $this->blog_id; 163 165 } 164 166 … … 405 407 406 408 return false; 407 409 } 410 411 private function get_blog_id() { 412 global $wpdb; 413 if ( empty( $this->blog_id ) ) { 414 $blog_id = get_network_option( $this->id, 'main_site' ); 415 if ( ! $blog_id ) { 416 $blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $this->domain, $this->path ) ); 417 if ( ! $blog_id ) { 418 add_network_option( $this->id, 'main_site', $blog_id ); 419 } 420 } 421 if ( $blog_id ) { 422 $this->blog_id = $blog_id; 423 } 424 } 425 } 408 426 } -
src/wp-includes/ms-load.php
426 426 if ( empty( $current_site->blog_id ) ) { 427 427 if ( $current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path ) { 428 428 $current_site->blog_id = $current_blog->blog_id; 429 } elseif ( ! $current_site->blog_id = wp_cache_get( 'network:' . $current_site->id . ':main_site', 'site-options' ) ) {429 } elseif ( ! $current_site->blog_id = get_network_option( $current_site->id, 'main_site' ) ) { 430 430 $current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", 431 431 $current_site->domain, $current_site->path ) ); 432 wp_cache_add( 'network:' . $current_site->id . ':main_site', $current_site->blog_id, 'site-options');432 add_network_option( $current_site->id, 'main_site', $current_site->blog_id ); 433 433 } 434 434 } 435 435