Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/16/2014 09:47:18 PM (8 years ago)
Author:
boonebgorges
Message:

Introduce $args param to BP_Groups_Group constructor and groups_get_group()

This argument array can contain the following toggles:

  • update_meta_cache (pre-fetch all group metadata for the queried group)
  • populate_extras (pre-fetch last activity, admin/mod lists, and current user access/membership status in queried group)

Both items default to false, for backward compatibility

Allowing these pre-fetch toggles to be set to false allows us to avoid large
numbers of unnecessary database queries in certain cases, such as when
secondary avatars are populated on activity directories.

See #5398

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-functions.php

    r7897 r7898  
    4242function groups_get_group( $args = '' ) {
    4343    $defaults = array(
    44         'group_id'   => false,
    45         'load_users' => false
     44        'group_id'          => false,
     45        'load_users'        => false,
     46        'populate_extras'   => true,
     47        'update_meta_cache' => true,
    4648    );
    4749
     
    5254
    5355    if ( !$group = wp_cache_get( $cache_key, 'bp' ) ) {
    54         $group = new BP_Groups_Group( $group_id, true, $load_users );
     56        $group_args = array(
     57            'populate_extras'   => $populate_extras,
     58            'update_meta_cache' => $update_meta_cache,
     59        );
     60
     61        $group = new BP_Groups_Group( $group_id, $group_args );
    5562        wp_cache_set( $cache_key, $group, 'bp' );
    5663    }
Note: See TracChangeset for help on using the changeset viewer.