Ticket #29684: 29684.3.diff
File 29684.3.diff, 2.0 KB (added by , 7 years ago) |
---|
-
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