Skip to:
Content

BuddyPress.org

Ticket #4758: 6716.patch

File 6716.patch, 1.0 KB (added by johnjamesjacoby, 14 years ago)
  • bp-forums/bp-forums-functions.php

     
    352352 * @param int $user_id The user id
    353353 */
    354354function bp_forums_reply_exists( $text = '', $topic_id = 0, $user_id = 0 ) {
    355         global $wpdb;
    356355
    357         $reply_exists = false;
    358 
    359356        if ( $text && $topic_id && $user_id ) {
    360357                do_action( 'bbpress_init' );
    361358
    362                 $args = array(
     359                $query = new BB_Query( 'post', array(
    363360                        'post_author_id' => $user_id,
    364                         'topic_id'       => $topic_id
    365                 );
     361                        'topic_id'       => $topic_id,
     362                        'post_text'      => $text
     363                ) );
    366364
    367                 // BB_Query's post_text parameter does a MATCH, while we need exact matches
    368                 add_filter( 'get_posts_where', create_function( '$q', 'return $q . " AND p.post_text = \'' . $wpdb->escape( $text ) . '\'";' ) );
    369 
    370                 $query = new BB_Query( 'post', $args );
    371 
    372365                $reply_exists = !empty( $query->results );
     366        } else {
     367                $reply_exists = false;
    373368        }
    374369
    375370        return apply_filters( 'bp_forums_reply_exists', $reply_exists, $text, $topic_id, $user_id );