Skip to:
Content

bbPress.org

Changeset 5774


Ignore:
Timestamp:
05/21/2015 08:50:34 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Cache: Much more sane cache invalidation.

This change improves hierarchical forum/topic/reply cache invalidations by not requiring each call to be strategically placed between actions to avoid race conditions.

Props thebrandonallen. Fixes #2800.

Location:
trunk/src/includes/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/actions.php

    r5770 r5774  
    295295add_action( 'bbp_new_reply_post_extras', 'bbp_clean_post_cache' );
    296296
    297 // Clean caches on deleted/spammed/unspammed/trashed/untrashed actions
    298 add_action( 'bbp_approved_reply',   'bbp_clean_post_cache', 999 );
    299 add_action( 'bbp_approved_topic',   'bbp_clean_post_cache', 999 );
    300 add_action( 'bbp_deleted_reply',    'bbp_clean_post_cache', 999 );
    301 add_action( 'bbp_deleted_topic',    'bbp_clean_post_cache', 999 );
    302 add_action( 'bbp_spammed_reply',    'bbp_clean_post_cache', 999 );
    303 add_action( 'bbp_spammed_topic',    'bbp_clean_post_cache', 999 );
    304 add_action( 'bbp_trashed_reply',    'bbp_clean_post_cache', 999 );
    305 add_action( 'bbp_trashed_topic',    'bbp_clean_post_cache', 999 );
    306 add_action( 'bbp_unapproved_reply', 'bbp_clean_post_cache', 999 );
    307 add_action( 'bbp_unapproved_topic', 'bbp_clean_post_cache', 999 );
    308 add_action( 'bbp_unspammed_reply',  'bbp_clean_post_cache', 999 );
    309 add_action( 'bbp_unspammed_topic',  'bbp_clean_post_cache', 999 );
    310 add_action( 'bbp_untrashed_reply',  'bbp_clean_post_cache', 999 );
    311 add_action( 'bbp_untrashed_topic',  'bbp_clean_post_cache', 999 );
     297// Clean bbPress post caches when WordPress's is cleaned
     298add_action( 'clean_post_cache', 'bbp_clean_post_cache' );
    312299
    313300/**
  • trunk/src/includes/core/cache.php

    r5770 r5774  
    142142    }
    143143
     144    // Child query types to clean
     145    $post_types = array(
     146        bbp_get_forum_post_type(),
     147        bbp_get_topic_post_type(),
     148        bbp_get_reply_post_type()
     149    );
     150
     151    // Bail if not a bbPress post type
     152    if ( ! in_array( $_post->post_type, $post_types, true ) ) {
     153        return;
     154    }
     155
    144156    wp_cache_delete( $_post->ID, 'posts'     );
    145157    wp_cache_delete( $_post->ID, 'post_meta' );
     
    148160
    149161    do_action( 'bbp_clean_post_cache', $_post->ID, $_post );
    150 
    151     // Child query types to clean
    152     $post_types = array(
    153         bbp_get_topic_post_type(),
    154         bbp_get_forum_post_type(),
    155         bbp_get_reply_post_type()
    156     );
    157162
    158163    // Loop through query types and clean caches
Note: See TracChangeset for help on using the changeset viewer.