Skip to:
Content

bbPress.org

Ticket #2800: 2800.02.patch

File 2800.02.patch, 2.7 KB (added by thebrandonallen, 10 years ago)

Cache cleaning improvements

  • src/includes/core/actions.php

    diff --git src/includes/core/actions.php src/includes/core/actions.php
    index 030d46d..e84fe22 100644
    add_action( 'bbp_new_topic_post_extras', 'bbp_clean_post_cache' ); 
    294294add_action( 'bbp_new_reply_pre_extras',  'bbp_clean_post_cache' );
    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 our cache when WP cleans theirs
     298add_action( 'clean_post_cache', 'bbp_clean_post_cache' );
    312299
    313300/**
    314301 * bbPress needs to redirect the user around in a few different circumstances:
  • src/includes/core/cache.php

    diff --git src/includes/core/cache.php src/includes/core/cache.php
    index a4f573c..c2a49f6 100644
    function bbp_clean_post_cache( $_post = '' ) { 
    141141                return;
    142142        }
    143143
    144         wp_cache_delete( $_post->ID, 'posts'     );
    145         wp_cache_delete( $_post->ID, 'post_meta' );
    146 
    147         clean_object_term_cache( $_post->ID, $_post->post_type );
    148 
    149         do_action( 'bbp_clean_post_cache', $_post->ID, $_post );
    150 
    151144        // Child query types to clean
    152145        $post_types = array(
    153146                bbp_get_topic_post_type(),
    function bbp_clean_post_cache( $_post = '' ) { 
    155148                bbp_get_reply_post_type()
    156149        );
    157150
     151        // Make sure we're working with BBP post types
     152        if ( ! in_array( $_post->post_type, $post_types ) ) {
     153                return;
     154        }
     155
     156        wp_cache_delete( $_post->ID, 'posts'     );
     157        wp_cache_delete( $_post->ID, 'post_meta' );
     158
     159        clean_object_term_cache( $_post->ID, $_post->post_type );
     160
     161        do_action( 'bbp_clean_post_cache', $_post->ID, $_post );
     162
    158163        // Loop through query types and clean caches
    159164        foreach ( $post_types as $post_type ) {
    160165                wp_cache_delete( 'bbp_get_forum_'     . $_post->ID . '_reply_id',                              'bbpress_posts' );