After [28613], also kill queries that explicityly pass empty arrays to `category__in`, `tag__in`, `tag_slug__in`, and `author__in` to `WP_Query`.
Adds unit tests. Fixes #28099. Built from https://develop.svn.wordpress.org/trunk@28664 git-svn-id: http://core.svn.wordpress.org/trunk@28482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
aea136ec06
commit
23a53beb7e
|
@ -1830,6 +1830,8 @@ class WP_Query {
|
||||||
'field' => 'term_id',
|
'field' => 'term_id',
|
||||||
'include_children' => false
|
'include_children' => false
|
||||||
);
|
);
|
||||||
|
} elseif ( isset( $this->query['category__in'] ) ) {
|
||||||
|
$q['category__in'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($q['category__not_in']) ) {
|
if ( ! empty($q['category__not_in']) ) {
|
||||||
|
@ -1887,6 +1889,8 @@ class WP_Query {
|
||||||
'taxonomy' => 'post_tag',
|
'taxonomy' => 'post_tag',
|
||||||
'terms' => $q['tag__in']
|
'terms' => $q['tag__in']
|
||||||
);
|
);
|
||||||
|
} elseif ( isset( $this->query['tag__in'] ) ) {
|
||||||
|
$q['tag__in'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($q['tag__not_in']) ) {
|
if ( !empty($q['tag__not_in']) ) {
|
||||||
|
@ -1914,6 +1918,8 @@ class WP_Query {
|
||||||
'terms' => $q['tag_slug__in'],
|
'terms' => $q['tag_slug__in'],
|
||||||
'field' => 'slug'
|
'field' => 'slug'
|
||||||
);
|
);
|
||||||
|
} elseif ( isset( $this->query['tag_slug__in'] ) ) {
|
||||||
|
$q['tag_slug__in'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($q['tag_slug__and']) ) {
|
if ( !empty($q['tag_slug__and']) ) {
|
||||||
|
@ -2500,6 +2506,13 @@ class WP_Query {
|
||||||
$where .= $clauses['where'];
|
$where .= $clauses['where'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If *__in is passed to WP_Query as an empty array, don't return results
|
||||||
|
foreach ( array( 'category', 'tag', 'tag_slug' ) as $in ) {
|
||||||
|
if ( isset( $q["{$in}__in"] ) && false === $q["{$in}__in"] ) {
|
||||||
|
$where = " AND 1=0 $where";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $this->is_tax ) {
|
if ( $this->is_tax ) {
|
||||||
if ( empty($post_type) ) {
|
if ( empty($post_type) ) {
|
||||||
// Do a fully inclusive search for currently registered post types of queried taxonomies
|
// Do a fully inclusive search for currently registered post types of queried taxonomies
|
||||||
|
@ -2591,6 +2604,9 @@ class WP_Query {
|
||||||
} elseif ( ! empty( $q['author__in'] ) ) {
|
} elseif ( ! empty( $q['author__in'] ) ) {
|
||||||
$author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) );
|
$author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) );
|
||||||
$where .= " AND {$wpdb->posts}.post_author IN ($author__in) ";
|
$where .= " AND {$wpdb->posts}.post_author IN ($author__in) ";
|
||||||
|
} elseif ( isset( $this->query['author__in'] ) ) {
|
||||||
|
$author__in = 0;
|
||||||
|
$where .= ' AND 1=0 ';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Author stuff for nice URLs
|
// Author stuff for nice URLs
|
||||||
|
|
Loading…
Reference in New Issue