Revert [28613] and [28664]. A good idea, but too much BC baggage.
See #28099. git-svn-id: https://develop.svn.wordpress.org/trunk@28783 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
dbc30e94b3
commit
5ec545d5ab
@ -1830,8 +1830,6 @@ class WP_Query {
|
||||
'field' => 'term_id',
|
||||
'include_children' => false
|
||||
);
|
||||
} elseif ( isset( $this->query['category__in'] ) ) {
|
||||
$q['category__in'] = false;
|
||||
}
|
||||
|
||||
if ( ! empty($q['category__not_in']) ) {
|
||||
@ -1889,8 +1887,6 @@ class WP_Query {
|
||||
'taxonomy' => 'post_tag',
|
||||
'terms' => $q['tag__in']
|
||||
);
|
||||
} elseif ( isset( $this->query['tag__in'] ) ) {
|
||||
$q['tag__in'] = false;
|
||||
}
|
||||
|
||||
if ( !empty($q['tag__not_in']) ) {
|
||||
@ -1918,8 +1914,6 @@ class WP_Query {
|
||||
'terms' => $q['tag_slug__in'],
|
||||
'field' => 'slug'
|
||||
);
|
||||
} elseif ( isset( $this->query['tag_slug__in'] ) ) {
|
||||
$q['tag_slug__in'] = false;
|
||||
}
|
||||
|
||||
if ( !empty($q['tag_slug__and']) ) {
|
||||
@ -2453,9 +2447,6 @@ class WP_Query {
|
||||
} elseif ( $q['post__in'] ) {
|
||||
$post__in = implode(',', array_map( 'absint', $q['post__in'] ));
|
||||
$where .= " AND {$wpdb->posts}.ID IN ($post__in)";
|
||||
} elseif ( isset( $this->query['post__in'] ) ) {
|
||||
$post__in = 0;
|
||||
$where .= " AND 1=0 ";
|
||||
} elseif ( $q['post__not_in'] ) {
|
||||
$post__not_in = implode(',', array_map( 'absint', $q['post__not_in'] ));
|
||||
$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
|
||||
@ -2466,9 +2457,6 @@ class WP_Query {
|
||||
} elseif ( $q['post_parent__in'] ) {
|
||||
$post_parent__in = implode( ',', array_map( 'absint', $q['post_parent__in'] ) );
|
||||
$where .= " AND {$wpdb->posts}.post_parent IN ($post_parent__in)";
|
||||
} elseif ( isset( $this->query['post_parent__in'] ) ) {
|
||||
$post_parent__in = 0;
|
||||
$where .= " AND 1=0 ";
|
||||
} elseif ( $q['post_parent__not_in'] ) {
|
||||
$post_parent__not_in = implode( ',', array_map( 'absint', $q['post_parent__not_in'] ) );
|
||||
$where .= " AND {$wpdb->posts}.post_parent NOT IN ($post_parent__not_in)";
|
||||
@ -2508,13 +2496,6 @@ class WP_Query {
|
||||
$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 ( empty($post_type) ) {
|
||||
// Do a fully inclusive search for currently registered post types of queried taxonomies
|
||||
@ -2606,9 +2587,6 @@ class WP_Query {
|
||||
} elseif ( ! empty( $q['author__in'] ) ) {
|
||||
$author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['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
|
||||
|
@ -402,13 +402,16 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28099
|
||||
*/
|
||||
function test_empty_post__in() {
|
||||
$posts1 = $this->q->query( array() );
|
||||
$this->assertNotEmpty( $posts1 );
|
||||
$posts2 = $this->q->query( array( 'post__in' => array() ) );
|
||||
$this->assertEmpty( $posts2 );
|
||||
$this->assertNotEmpty( $posts2 );
|
||||
$posts3 = $this->q->query( array( 'post_parent__in' => array() ) );
|
||||
$this->assertEmpty( $posts3 );
|
||||
$this->assertNotEmpty( $posts3 );
|
||||
}
|
||||
|
||||
function test_exlude_from_search_empty() {
|
||||
@ -514,7 +517,7 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||
$this->assertEqualSets( array( $author_1, $author_2 ), $author_ids );
|
||||
|
||||
$posts = $this->q->query( array( 'author__in' => array() ) );
|
||||
$this->assertEmpty( $posts );
|
||||
$this->assertNotEmpty( $posts );
|
||||
|
||||
$posts = $this->q->query( array(
|
||||
'author__not_in' => array( $author_1, $author_2 ),
|
||||
|
@ -203,6 +203,9 @@ class Tests_Tax_Query extends WP_UnitTestCase {
|
||||
$this->assertEquals( array( $posts[0], $posts[3] ), $results2, 'Relation: AND; Operator: IN' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28099
|
||||
*/
|
||||
function test_empty__in() {
|
||||
$cat_id = $this->factory->category->create();
|
||||
$post_id = $this->factory->post->create();
|
||||
@ -211,7 +214,7 @@ class Tests_Tax_Query extends WP_UnitTestCase {
|
||||
$q1 = get_posts( array( 'category__in' => array( $cat_id ) ) );
|
||||
$this->assertNotEmpty( $q1 );
|
||||
$q2 = get_posts( array( 'category__in' => array() ) );
|
||||
$this->assertEmpty( $q2 );
|
||||
$this->assertNotEmpty( $q2 );
|
||||
|
||||
$tag = wp_insert_term( 'woo', 'post_tag' );
|
||||
$tag_id = $tag['term_id'];
|
||||
@ -221,11 +224,11 @@ class Tests_Tax_Query extends WP_UnitTestCase {
|
||||
$q3 = get_posts( array( 'tag__in' => array( $tag_id ) ) );
|
||||
$this->assertNotEmpty( $q3 );
|
||||
$q4 = get_posts( array( 'tag__in' => array() ) );
|
||||
$this->assertEmpty( $q4 );
|
||||
$this->assertNotEmpty( $q4 );
|
||||
|
||||
$q5 = get_posts( array( 'tag_slug__in' => array( $slug ) ) );
|
||||
$this->assertNotEmpty( $q5 );
|
||||
$q6 = get_posts( array( 'tag_slug__in' => array() ) );
|
||||
$this->assertEmpty( $q6 );
|
||||
$this->assertNotEmpty( $q6 );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user