WordPress.org

Make WordPress Core

Changeset 27664


Ignore:
Timestamp:
03/24/2014 01:00:17 AM (5 years ago)
Author:
nacin
Message:

Multisite load: Cache the main site lookup query.

props jeremyfelt.
see #27003.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-settings.php

    r27663 r27664  
    173173        if ( $current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path ) {
    174174            $current_site->blog_id = $current_blog->blog_id;
    175         } else {
    176             // @todo we should be able to cache the blog ID of a network's main site easily.
     175        } elseif ( ! $current_site->blog_id = wp_cache_get( 'network:' . $current_site->id . ':main_site', 'site-options' ) ) {
    177176            $current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s",
    178177                $current_site->domain, $current_site->path ) );
     178            wp_cache_add( 'network:' . $current_site->id . ':main_site', $current_site->blog_id, 'site-options' );
    179179        }
    180180    }
Note: See TracChangeset for help on using the changeset viewer.