Skip to:
Content

BuddyPress.org

Ticket #8296: 8296.2.patch

File 8296.2.patch, 2.6 KB (added by imath, 3 years ago)
  • src/bp-activity/bp-activity-cache.php

    diff --git src/bp-activity/bp-activity-cache.php src/bp-activity/bp-activity-cache.php
    index da7542770..d1105d559 100644
    function bp_activity_update_meta_cache( $activity_ids = false ) { 
    4747function bp_activity_clear_cache_for_activity( $activity ) {
    4848        wp_cache_delete( $activity->id, 'bp_activity' );
    4949        wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
     50
     51        // Also clear the comments cache for the parent activity ID.
     52        if ( 'activity_comment' === $activity->type ) {
     53                wp_cache_delete( $activity->item_id, 'bp_activity_comments' );
     54        }
    5055}
    5156add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' );
    5257
  • src/bp-activity/bp-activity-functions.php

    diff --git src/bp-activity/bp-activity-functions.php src/bp-activity/bp-activity-functions.php
    index cf9410657..5c63e342f 100644
    function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) { 
    35473547        // Clear the activity stream first page cache.
    35483548        wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    35493549
     3550        if ( 'activity_comment' === $activity->type ) {
     3551                $activity_id = $activity->item_id;
     3552        } else {
     3553                $activity_id = $activity->id;
     3554
     3555                // Clear the activity cache for this activity item.
     3556                wp_cache_delete( $activity->id, 'bp_activity' );
     3557        }
     3558
    35503559        // Clear the activity comment cache for this activity item.
    3551         wp_cache_delete( $activity->id, 'bp_activity_comments' );
     3560        wp_cache_delete( $activity_id, 'bp_activity_comments' );
    35523561
    35533562        // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity.
    35543563        if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
    function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) { 
    35943603        // Clear the activity stream first page cache.
    35953604        wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    35963605
    3597         // Clear the activity comment cache for this activity item.
    3598         wp_cache_delete( $activity->id, 'bp_activity_comments' );
     3606        if ( 'activity_comment' === $activity->type ) {
     3607                $activity_id = $activity->item_id;
     3608        } else {
     3609                $activity_id = $activity->id;
     3610
     3611                // Clear the activity cache for this activity item.
     3612                wp_cache_delete( $activity->id, 'bp_activity' );
     3613        }
     3614
     3615        // Purge comment cache for the root activity update.
     3616        wp_cache_delete( $activity_id, 'bp_activity_comments' );
    35993617
    36003618        // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity.
    36013619        if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {