Skip to:
Content

bbPress.org

Changeset 3128


Ignore:
Timestamp:
05/10/2011 03:23:35 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Fix incorrect topic voice count routine, causing all topics to only show 1 voice. This will auto correct existing topics as new replies are created in them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r3125 r3128  
    17331733        return;
    17341734
    1735     // There should always be at least 1 voice
    1736     if ( !$voices = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = 'publish' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) ) )
    1737         $voices = 1;
    1738 
     1735    // Query the DB to get voices in this topic
     1736    $voices = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = 'publish' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
     1737
     1738    // If there's an error, make sure we at least have 1 voice
     1739    $voices = ( empty( $voices ) || is_wp_error( $voices )) ? 1 : $voices[0];
     1740
     1741    // Update the voice count for this topic id
    17391742    update_post_meta( $topic_id, '_bbp_voice_count', (int) $voices );
    17401743
Note: See TracChangeset for help on using the changeset viewer.