Skip to:
Content

bbPress.org

Changeset 4848


Ignore:
Timestamp:
04/15/2013 01:09:37 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Remove the global cache group, and update existing cache group keys to be more descriptive. Fixes issues with cached queries stomping each other on multisite installations. Fixes #2294.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bbpress.php

    r4842 r4848  
    267267        $this->errors         = new WP_Error(); // Feedback
    268268        $this->tab_index      = apply_filters( 'bbp_default_tab_index', 100 );
    269 
    270         /** Cache *************************************************************/
    271 
    272         // Add bbPress to global cache groups
    273         wp_cache_add_global_groups( 'bbpress' );
    274269    }
    275270
  • trunk/includes/common/functions.php

    r4847 r4848  
    12561256
    12571257    // Check for cache and set if needed
    1258     $child_id = wp_cache_get( $cache_id, 'bbpress' );
     1258    $child_id = wp_cache_get( $cache_id, 'bbpress_posts' );
    12591259    if ( empty( $child_id ) ) {
    12601260        $child_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) );
    1261         wp_cache_set( $cache_id, $child_id, 'bbpress' );
     1261        wp_cache_set( $cache_id, $child_id, 'bbpress_posts' );
    12621262    }
    12631263
     
    12991299
    13001300    // Check for cache and set if needed
    1301     $child_count = wp_cache_get( $cache_id, 'bbpress' );
     1301    $child_count = wp_cache_get( $cache_id, 'bbpress_posts' );
    13021302    if ( empty( $child_count ) ) {
    13031303        $child_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $parent_id, $post_type ) );
    1304         wp_cache_set( $cache_id, $child_count, 'bbpress' );
     1304        wp_cache_set( $cache_id, $child_count, 'bbpress_posts' );
    13051305    }
    13061306
     
    13421342
    13431343    // Check for cache and set if needed
    1344     $child_ids = wp_cache_get( $cache_id, 'bbpress' );
     1344    $child_ids = wp_cache_get( $cache_id, 'bbpress_posts' );
    13451345    if ( empty( $child_ids ) ) {
    13461346        $child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
    1347         wp_cache_set( $cache_id, $child_ids, 'bbpress' );
     1347        wp_cache_set( $cache_id, $child_ids, 'bbpress_posts' );
    13481348    }
    13491349
     
    14031403
    14041404    // Check for cache and set if needed
    1405     $child_ids = wp_cache_get( $cache_id, 'bbpress' );
     1405    $child_ids = wp_cache_get( $cache_id, 'bbpress_posts' );
    14061406    if ( empty( $child_ids ) ) {
    14071407        $child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
    1408         wp_cache_set( $cache_id, $child_ids, 'bbpress' );
     1408        wp_cache_set( $cache_id, $child_ids, 'bbpress_posts' );
    14091409    }
    14101410
  • trunk/includes/forums/functions.php

    r4819 r4848  
    17951795
    17961796    $cache_id = 'bbp_get_forum_' . $forum_id . '_reply_id';
    1797     $reply_id = (int) wp_cache_get( $cache_id, 'bbpress' );
     1797    $reply_id = (int) wp_cache_get( $cache_id, 'bbpress_posts' );
    17981798
    17991799    if ( empty( $reply_id ) ) {
     
    18051805        if ( !empty( $topic_ids ) ) {
    18061806            $reply_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
    1807             wp_cache_set( $cache_id, $reply_id, 'bbpress' ); // May be (int) 0
     1807            wp_cache_set( $cache_id, $reply_id, 'bbpress_posts' ); // May be (int) 0
    18081808        } else {
    1809             wp_cache_set( $cache_id, '0', 'bbpress' );
     1809            wp_cache_set( $cache_id, '0', 'bbpress_posts' );
    18101810        }
    18111811    }
  • trunk/includes/users/functions.php

    r4783 r4848  
    532532
    533533    $key   = $wpdb->prefix . '_bbp_subscriptions';
    534     $users = wp_cache_get( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress' );
     534    $users = wp_cache_get( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress_users' );
    535535    if ( empty( $users ) ) {
    536536        $users = $wpdb->get_col( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$topic_id}', meta_value) > 0" );
    537         wp_cache_set( 'bbp_get_topic_subscribers_' . $topic_id, $users, 'bbpress' );
     537        wp_cache_set( 'bbp_get_topic_subscribers_' . $topic_id, $users, 'bbpress_users' );
    538538    }
    539539
Note: See TracChangeset for help on using the changeset viewer.