Skip to:
Content

BuddyPress.org

Changeset 3660


Ignore:
Timestamp:
01/05/2011 10:03:41 PM (14 years ago)
Author:
djpaul
Message:

Speed up forum directory's "last active" bbPress SQL query to stop it fetching information we aren't using. Helps fix #2421

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums.php

    r3659 r3660  
    373373    do_action( 'bbpress_init' );
    374374
    375     $count = $bbdb->get_results( $bbdb->prepare( "SELECT t.topic_id FROM {$bbdb->topics} AS t". groups_add_forum_tables_sql( '' ) . " WHERE " . groups_add_forum_where_sql( "t.topic_status = '0'" ) ) );
     375    $count = $bbdb->get_results( $bbdb->prepare( "SELECT t.topic_id FROM {$bbdb->topics} AS t". groups_add_forum_tables_sql( '' ) . " WHERE " . groups_add_forum_where_sql( "t.topic_status = 0" ) ) );
    376376    return apply_filters( 'bp_forums_total_topic_count', count( (array)$count ) );
    377377}
     
    547547}
    548548
    549 
    550549function bp_forums_get_forum_topicpost_count( $forum_id ) {
    551550    global $wpdb, $bbdb;
     
    556555    return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );
    557556}
    558 
    559557
    560558function bp_forums_filter_caps( $allcaps ) {
     
    589587add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' );
    590588add_action( 'bp_forums_new_post', 'bp_core_clear_cache' );
    591 
    592589?>
  • trunk/bp-forums/bp-forums-filters.php

    r3592 r3660  
    132132add_filter( 'bp_get_the_topic_post_edit_text', 'bp_forums_strip_mentions_on_post_edit' );
    133133add_filter( 'bp_get_the_topic_text', 'bp_forums_strip_mentions_on_post_edit' );
    134 
    135134?>
  • trunk/bp-groups/bp-groups-filters.php

    r3369 r3660  
    106106add_filter( 'bb_current_user_can', 'groups_filter_bbpress_caps', 10, 3 );
    107107
     108/**
     109 * Amends the forum directory's "last active" bbPress SQL query to stop it fetching
     110 * information we aren't going to use. This speeds up the query.
     111 *
     112 * @see BB_Query::_filter_sql()
     113 * @since 1.3
     114 */
     115function groups_filter_forums_root_page_sql( $sql ) {
     116    return apply_filters( 'groups_filter_bbpress_root_page_sql', 't.topic_id' );
     117}
     118add_filter( 'get_latest_topics_fields', 'groups_filter_forums_root_page_sql' );
    108119?>
Note: See TracChangeset for help on using the changeset viewer.