Multisite load: Cache the main site lookup query.
props jeremyfelt. see #27003. git-svn-id: https://develop.svn.wordpress.org/trunk@27664 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
903c86d927
commit
9c520a5412
@ -172,10 +172,10 @@ if ( !isset( $current_site ) || !isset( $current_blog ) ) {
|
||||
if ( ! isset( $current_site->blog_id ) ) {
|
||||
if ( $current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path ) {
|
||||
$current_site->blog_id = $current_blog->blog_id;
|
||||
} else {
|
||||
// @todo we should be able to cache the blog ID of a network's main site easily.
|
||||
} elseif ( ! $current_site->blog_id = wp_cache_get( 'network:' . $current_site->id . ':main_site', 'site-options' ) ) {
|
||||
$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s",
|
||||
$current_site->domain, $current_site->path ) );
|
||||
wp_cache_add( 'network:' . $current_site->id . ':main_site', $current_site->blog_id, 'site-options' );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user