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:
Andrew Nacin 2014-03-24 01:00:17 +00:00
parent 903c86d927
commit 9c520a5412
1 changed files with 2 additions and 2 deletions

View File

@ -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' );
}
}