Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/21/2014 05:51:10 PM (10 years ago)
Author:
boonebgorges
Message:

Overhaul the way that individual group objects are cached

The existing implementation was broken in a number of ways. Most critically,
user-specific data (like is_member) was being stored in the persistent object
cache without respect to user.

This refactor excludes the user-specific data from being cached along with the
group object. It also reworks the way that items are keyed in the cache, for
greater consistency with WordPress and the other BP components.

See #5407

File:
1 edited

Legend:

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

    r7948 r7956  
    4141 */
    4242function groups_get_group( $args = '' ) {
    43     $defaults = array(
     43    $r = wp_parse_args( $args, array(
    4444        'group_id'          => false,
    4545        'load_users'        => false,
    4646        'populate_extras'   => true,
     47    ) );
     48
     49    $group_args = array(
     50        'populate_extras' => $r['populate_extras'],
    4751    );
    4852
    49     $args = wp_parse_args( $args, $defaults );
    50     extract( $args, EXTR_SKIP );
    51 
    52     $cache_key = 'bp_groups_group_' . $group_id . ( $load_users ? '_load_users' : '_noload_users' );
    53 
    54     if ( !$group = wp_cache_get( $cache_key, 'bp' ) ) {
    55         $group_args = array(
    56             'populate_extras'   => $populate_extras,
    57         );
    58 
    59         $group = new BP_Groups_Group( $group_id, $group_args );
    60         wp_cache_set( $cache_key, $group, 'bp' );
    61     }
     53    $group = new BP_Groups_Group( $r['group_id'], $group_args );
    6254
    6355    return apply_filters( 'groups_get_group', $group );
Note: See TracChangeset for help on using the changeset viewer.