WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/29/2016 07:31:49 PM (3 years ago)
Author:
jeremyfelt
Message:

Multisite: Lazy load extended WP_Site properties when requested.

In the past, get_blog_details() has been used to retrieve the home, siteurl, blogname, and post_count options for a site. By lazy loading properties in a WP_Site object, we can avoid having to use get_blog_details() and instead provide the properties as needed.

This introduces the global site-details cache group in which standard objects representing the site are stored. This will one day be a replacement for the blog-details cache group that is currently used in get_blog_details().

This relies on the ms_loaded action introduced in [37916] as properties are not available via get_option() until multisite has been fully loaded.

Props flixos90.
Fixes #36935.

File:
1 edited

Legend:

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

    r37895 r37918  
    456456
    457457    wp_cache_delete( $blog_id, 'sites' );
     458    wp_cache_delete( $blog_id, 'site-details' );
    458459    wp_cache_delete( $blog_id , 'blog-details' );
    459460    wp_cache_delete( $blog_id . 'short' , 'blog-details' );
     
    823824                wp_cache_add_global_groups( $global_groups );
    824825            } else {
    825                 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' ) );
     826                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', 'site-details' ) );
    826827            }
    827828            wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
     
    894895                wp_cache_add_global_groups( $global_groups );
    895896            } else {
    896                 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' ) );
     897                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', 'site-details' ) );
    897898            }
    898899            wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
Note: See TracChangeset for help on using the changeset viewer.