Make WordPress Core


Ignore:
Timestamp:
01/25/2016 09:51:01 PM (11 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.

File:
1 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' ) );
Note: See TracChangeset for help on using the changeset viewer.