Make WordPress Core


Ignore:
Timestamp:
02/05/2016 06:49:46 PM (10 years ago)
Author:
boonebgorges
Message:

Comments: Restore the ability to bypass post_id filter using 0 or '0'.

The changes introduced in [36381], while logical and clearly awesome, introduce
the potential for much breakage. Those who want to query for comments with a
null comment_post_ID should use 'post_in' => array( 0 ) instead.

Reverts [36381], [36387].
See #35090.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-comment-query.php

    r36479 r36480  
    215215     *     @type int          $post_ID                   Currently unused.
    216216     *     @type int          $post_id                   Limit results to those affiliated with a given post ID.
    217      *                                                   Default null.
     217     *                                                   Default 0.
    218218     *     @type array        $post__in                  Array of post IDs to include affiliated comments for.
    219219     *                                                   Default empty.
     
    279279            'post_author__not_in' => '',
    280280            'post_ID' => '',
    281             'post_id' => null,
     281            'post_id' => 0,
    282282            'post__in' => '',
    283283            'post__not_in' => '',
     
    648648        }
    649649
    650         if ( strlen( $this->query_vars['post_id'] ) ) {
    651             $this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $this->query_vars['post_id'] );
     650        $post_id = absint( $this->query_vars['post_id'] );
     651        if ( ! empty( $post_id ) ) {
     652            $this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $post_id );
    652653        }
    653654
Note: See TracChangeset for help on using the changeset viewer.