Skip to:
Content

bbPress.org

Changeset 5858


Ignore:
Timestamp:
07/16/2015 04:15:12 AM (6 years ago)
Author:
johnjamesjacoby
Message:

Queries: Clean up post status concatenation in 2 queries.

This changeset moves array of "hidden" type post-statuses into their own variable to better match existing usages.

Fixes #2826.

Location:
trunk/src/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/forums/functions.php

    r5856 r5858  
    15861586        // Get topics of forum
    15871587        if ( empty( $topic_count ) ) {
     1588            $statuses    = array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() );
     1589            $post_status = "'" . implode( "','", $statuses ) . "'";
    15881590            $bbp_db      = bbp_db();
    1589             $post_status = "'" . implode( "','", array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() ) ) . "'";
    15901591            $topic_count = $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(ID) FROM {$bbp_db->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $forum_id, bbp_get_topic_post_type() ) );
    15911592        }
  • trunk/src/includes/topics/functions.php

    r5837 r5858  
    25192519    // Get replies of topic
    25202520    if ( empty( $reply_count ) ) {
     2521        $statuses    = array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() );
     2522        $post_status = "'" . implode( "','", $statuses ) . "'";
    25212523        $bbp_db      = bbp_db();
    2522         $post_status = "'" . implode( "','", array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() ) ) . "'";
    25232524        $query       = $bbp_db->prepare( "SELECT COUNT(ID) FROM {$bbp_db->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() );
    25242525        $reply_count = $bbp_db->get_var( $query );
Note: See TracChangeset for help on using the changeset viewer.