Skip to:
Content

BuddyPress.org

Changeset 7791


Ignore:
Timestamp:
02/05/2014 07:16:55 PM (11 years ago)
Author:
boonebgorges
Message:

Improve cache invalidation for xprofile groups

XProfile groups are cached in two ways: individually and as a collection. This
changeset improves group cache invalidation by ensuring that both of these
caches are wiped when child fields are added or edited.

See #1332

Location:
trunk/bp-xprofile
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-cache.php

    r7786 r7791  
    1818    wp_cache_delete( 'xprofile_group_' . $group_obj->id, 'bp' );
    1919}
    20 add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' );
    21 add_action( 'xprofile_groups_saved_group',   'xprofile_clear_profile_groups_object_cache' );
     20add_action( 'xprofile_group_after_delete', 'xprofile_clear_profile_groups_object_cache' );
     21add_action( 'xprofile_group_after_save',   'xprofile_clear_profile_groups_object_cache' );
    2222
    2323function xprofile_clear_profile_data_object_cache( $group_id ) {
     
    3636    // Clear default visibility level cache
    3737    wp_cache_delete( 'xprofile_default_visibility_levels', 'bp' );
     38
     39    // Modified fields can alter parent group status, in particular when
     40    // the group goes from empty to non-empty. Bust its cache, as well as
     41    // the global group_inc_empty cache
     42    wp_cache_delete( 'xprofile_group_' . $field_obj->group_id, 'bp' );
     43    wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );
    3844}
    3945add_action( 'xprofile_fields_saved_field', 'xprofile_clear_profile_field_object_cache' );
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r7786 r7791  
    7575            return false;
    7676
     77        do_action_ref_array( 'xprofile_group_before_delete', array( &$this ) );
     78
    7779        // Delete field group
    7880        if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id ) ) ) {
     
    8890                }
    8991            }
     92
     93            do_action_ref_array( 'xprofile_group_after_delete', array( &$this ) );
    9094
    9195            return true;
Note: See TracChangeset for help on using the changeset viewer.