Allow comment query results to be limited to comments with comment_post_ID = 0.
Previously, this was not possible due to an overly broad `empty()` check. Passing `null`, `false`, or `''` to 'post_id', or omitting 'post_id' altogether, will continue to return comments regardless of `comment_post_ID`, as before. Passing `0` or `'0'` will limit results to comments with no associated post. Props danielbachhuber. Fixes #35090. Built from https://develop.svn.wordpress.org/trunk@36381 git-svn-id: http://core.svn.wordpress.org/trunk@36348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
90b4ee93b3
commit
c5ab953773
|
@ -214,7 +214,7 @@ class WP_Comment_Query {
|
|||
* Default empty.
|
||||
* @type int $post_ID Currently unused.
|
||||
* @type int $post_id Limit results to those affiliated with a given post ID.
|
||||
* Default 0.
|
||||
* Default null.
|
||||
* @type array $post__in Array of post IDs to include affiliated comments for.
|
||||
* Default empty.
|
||||
* @type array $post__not_in Array of post IDs to exclude affiliated comments for.
|
||||
|
@ -276,7 +276,7 @@ class WP_Comment_Query {
|
|||
'post_author__in' => '',
|
||||
'post_author__not_in' => '',
|
||||
'post_ID' => '',
|
||||
'post_id' => 0,
|
||||
'post_id' => null,
|
||||
'post__in' => '',
|
||||
'post__not_in' => '',
|
||||
'post_author' => '',
|
||||
|
@ -645,9 +645,8 @@ class WP_Comment_Query {
|
|||
$fields = "$wpdb->comments.comment_ID";
|
||||
}
|
||||
|
||||
$post_id = absint( $this->query_vars['post_id'] );
|
||||
if ( ! empty( $post_id ) ) {
|
||||
$this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $post_id );
|
||||
if ( strlen( $this->query_vars['post_id'] ) ) {
|
||||
$this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $this->query_vars['post_id'] );
|
||||
}
|
||||
|
||||
// Parse comment IDs for an IN clause.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.5-alpha-36380';
|
||||
$wp_version = '4.5-alpha-36381';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue