Skip to:
Content

BuddyPress.org

Changeset 3659


Ignore:
Timestamp:
01/04/2011 10:54:44 PM (16 years ago)
Author:
djpaul
Message:

Improve speed of forums' total topic count by alot. Fixes #2421

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums.php

    r3657 r3659  
    369369
    370370function bp_forums_total_topic_count() {
    371         do_action( 'bbpress_init' );
    372 
    373         $query = new BB_Query( 'topic', array( 'page' => 1, 'per_page' => -1, 'count' => true ) );
    374         $count = $query->count;
    375         $query = null;
    376 
    377         return $count;
     371        global $bbdb;
     372
     373        do_action( 'bbpress_init' );
     374
     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'" ) ) );
     376        return apply_filters( 'bp_forums_total_topic_count', count( (array)$count ) );
    378377}
    379378
Note: See TracChangeset for help on using the changeset viewer.