Make WordPress Core

Changeset 36393


Ignore:
Timestamp:
01/25/2016 09:51:01 PM (9 years ago)
Author:
jeremyfelt
Message:

Multisite: Introduce the WP_Site class.

  • A WP_Site object initially matches a row from wp_blogs.
  • A site can be retrieved by its ID through WP_Site::get_instance().
  • Adds sites to the global cache group and captures instance lookups.
  • The multisite bootstrap now ensures $current_blog is an instance of WP_Site.

Props johnjamesjacoby, jeremyfelt.
See #32450.

Location:
trunk/src/wp-includes
Files:
1 added
2 edited

Legend:

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

    r36258 r36393  
    211211
    212212    if ( empty($details) ) {
    213         $details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $blog_id ) );
     213        $details = WP_Site::get_instance( $blog_id );
    214214        if ( ! $details ) {
    215215            // Set the full cache.
     
    217217            return false;
    218218        }
     219    }
     220
     221    if ( ! $details instanceof WP_Site ) {
     222        $details = new WP_Site( $details );
    219223    }
    220224
     
    443447    $domain_path_key = md5( $blog->domain . $blog->path );
    444448
     449    wp_cache_delete( $blog_id, 'sites' );
    445450    wp_cache_delete( $blog_id , 'blog-details' );
    446451    wp_cache_delete( $blog_id . 'short' , 'blog-details' );
     
    656661                wp_cache_add_global_groups( $global_groups );
    657662            } else {
    658                 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks' ) );
     663                wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );
    659664            }
    660665            wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
  • trunk/src/wp-includes/ms-settings.php

    r35782 r36393  
    1313/** WP_Network class */
    1414require_once( ABSPATH . WPINC . '/class-wp-network.php' );
     15
     16/** WP_Site class */
     17require_once( ABSPATH . WPINC . '/class-wp-site.php' );
    1518
    1619/** Multisite loader */
     
    223226}
    224227
     228if ( ! $current_blog instanceof WP_Site ) {
     229    $current_blog = new WP_Site( $current_blog );
     230}
     231
    225232// Define upload directory constants
    226233ms_upload_constants();
Note: See TracChangeset for help on using the changeset viewer.