Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/07/2014 01:32:04 AM (12 years ago)
Author:
boonebgorges
Message:

Improved cache invalidation when posting activity comments

  • Because activity comment caches are stored only with the top-level parent, we should be invalidating the bp_activity_comments cache for that item, not for the immediate parent
  • When a new comment is created, clear the bp_activity cache for each ancestor

See #5434

File:
1 edited

Legend:

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

    r8035 r8076  
    12411241    ) );
    12421242
    1243     // Clear the comment and item cache for this activity
    1244     wp_cache_delete( $parent_id, 'bp_activity_comments' );
    1245     wp_cache_delete( $parent_id, 'bp_activity' );
     1243    // Comment caches are stored only with the top-level item
     1244    wp_cache_delete( $activity_id, 'bp_activity_comments' );
     1245
     1246    // Walk the tree to clear caches for all parent items
     1247    $clear_id = $parent_id;
     1248    while ( $clear_id != $activity_id ) {
     1249        $clear_object = new BP_Activity_Activity( $clear_id );
     1250        wp_cache_delete( $clear_id, 'bp_activity' );
     1251        $clear_id = intval( $clear_object->secondary_item_id );
     1252    }
     1253    wp_cache_delete( $activity_id, 'bp_activity' );
    12461254
    12471255    do_action( 'bp_activity_comment_posted', $comment_id, $params, $activity );
Note: See TracChangeset for help on using the changeset viewer.