Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/18/2014 12:50:11 PM (13 years ago)
Author:
boonebgorges
Message:

Pre-fetch blogmeta when in blog loops

This reduces overhead when querying for blog meta in the context of a
bp_has_blogs() template loop. Mirrors similar functionality in the activity,
groups, and xprofile components.

Also introduces an update_meta_cache parameter to the bp_has_blogs() stack, so
that plugin/theme authors can disable this pre-fetching.

Fixes #5398

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-classes.php

    r7699 r7918  
    115115         * @param string|bool $search_terms Optional. Search by text stored in
    116116         *        blogmeta (such as the blog name). Default: false.
     117         * @param bool $update_meta_cache Whether to pre-fetch metadata for
     118         *        blogs. Default: true.
    117119         * @return array Multidimensional results array, structured as follows:
    118120         *           'blogs' - Array of located blog objects
    119121         *           'total' - A count of the total blogs matching the filter params
    120122         */
    121         public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false ) {
     123        public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true ) {
    122124                global $bp, $wpdb;
    123125
    … …  
    162164                $paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type );
    163165
     166                if ( $update_meta_cache ) {
     167                        bp_blogs_update_meta_cache( $blog_ids );
     168                }
     169
    164170                return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
    165171        }
Note: See TracChangeset for help on using the changeset viewer.