Changeset 28664
- Timestamp:
- 06/04/2014 05:49:26 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r28623 r28664 1831 1831 'include_children' => false 1832 1832 ); 1833 } elseif ( isset( $this->query['category__in'] ) ) { 1834 $q['category__in'] = false; 1833 1835 } 1834 1836 … … 1888 1890 'terms' => $q['tag__in'] 1889 1891 ); 1892 } elseif ( isset( $this->query['tag__in'] ) ) { 1893 $q['tag__in'] = false; 1890 1894 } 1891 1895 … … 1915 1919 'field' => 'slug' 1916 1920 ); 1921 } elseif ( isset( $this->query['tag_slug__in'] ) ) { 1922 $q['tag_slug__in'] = false; 1917 1923 } 1918 1924 … … 2501 2507 } 2502 2508 2509 // If *__in is passed to WP_Query as an empty array, don't return results 2510 foreach ( array( 'category', 'tag', 'tag_slug' ) as $in ) { 2511 if ( isset( $q["{$in}__in"] ) && false === $q["{$in}__in"] ) { 2512 $where = " AND 1=0 $where"; 2513 } 2514 } 2515 2503 2516 if ( $this->is_tax ) { 2504 2517 if ( empty($post_type) ) { … … 2592 2605 $author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) ); 2593 2606 $where .= " AND {$wpdb->posts}.post_author IN ($author__in) "; 2607 } elseif ( isset( $this->query['author__in'] ) ) { 2608 $author__in = 0; 2609 $where .= ' AND 1=0 '; 2594 2610 } 2595 2611 -
trunk/tests/phpunit/tests/query/results.php
r28613 r28664 514 514 $this->assertEqualSets( array( $author_1, $author_2 ), $author_ids ); 515 515 516 $posts = $this->q->query( array( 'author__in' => array() ) ); 517 $this->assertEmpty( $posts ); 518 516 519 $posts = $this->q->query( array( 517 520 'author__not_in' => array( $author_1, $author_2 ), -
trunk/tests/phpunit/tests/term/query.php
r28647 r28664 203 203 $this->assertEquals( array( $posts[0], $posts[3] ), $results2, 'Relation: AND; Operator: IN' ); 204 204 } 205 206 function test_empty__in() { 207 $cat_id = $this->factory->category->create(); 208 $post_id = $this->factory->post->create(); 209 wp_set_post_categories( $post_id, $cat_id ); 210 211 $q1 = get_posts( array( 'category__in' => array( $cat_id ) ) ); 212 $this->assertNotEmpty( $q1 ); 213 $q2 = get_posts( array( 'category__in' => array() ) ); 214 $this->assertEmpty( $q2 ); 215 216 $tag = wp_insert_term( 'woo', 'post_tag' ); 217 $tag_id = $tag['term_id']; 218 $slug = get_tag( $tag_id )->slug; 219 wp_set_post_tags( $post_id, $slug ); 220 221 $q3 = get_posts( array( 'tag__in' => array( $tag_id ) ) ); 222 $this->assertNotEmpty( $q3 ); 223 $q4 = get_posts( array( 'tag__in' => array() ) ); 224 $this->assertEmpty( $q4 ); 225 226 $q5 = get_posts( array( 'tag_slug__in' => array( $slug ) ) ); 227 $this->assertNotEmpty( $q5 ); 228 $q6 = get_posts( array( 'tag_slug__in' => array() ) ); 229 $this->assertEmpty( $q6 ); 230 } 205 231 }
Note: See TracChangeset
for help on using the changeset viewer.