Changeset 28783
- Timestamp:
- 06/20/2014 04:20:35 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r28737 r28783 1831 1831 'include_children' => false 1832 1832 ); 1833 } elseif ( isset( $this->query['category__in'] ) ) {1834 $q['category__in'] = false;1835 1833 } 1836 1834 … … 1890 1888 'terms' => $q['tag__in'] 1891 1889 ); 1892 } elseif ( isset( $this->query['tag__in'] ) ) {1893 $q['tag__in'] = false;1894 1890 } 1895 1891 … … 1919 1915 'field' => 'slug' 1920 1916 ); 1921 } elseif ( isset( $this->query['tag_slug__in'] ) ) {1922 $q['tag_slug__in'] = false;1923 1917 } 1924 1918 … … 2454 2448 $post__in = implode(',', array_map( 'absint', $q['post__in'] )); 2455 2449 $where .= " AND {$wpdb->posts}.ID IN ($post__in)"; 2456 } elseif ( isset( $this->query['post__in'] ) ) {2457 $post__in = 0;2458 $where .= " AND 1=0 ";2459 2450 } elseif ( $q['post__not_in'] ) { 2460 2451 $post__not_in = implode(',', array_map( 'absint', $q['post__not_in'] )); … … 2467 2458 $post_parent__in = implode( ',', array_map( 'absint', $q['post_parent__in'] ) ); 2468 2459 $where .= " AND {$wpdb->posts}.post_parent IN ($post_parent__in)"; 2469 } elseif ( isset( $this->query['post_parent__in'] ) ) {2470 $post_parent__in = 0;2471 $where .= " AND 1=0 ";2472 2460 } elseif ( $q['post_parent__not_in'] ) { 2473 2461 $post_parent__not_in = implode( ',', array_map( 'absint', $q['post_parent__not_in'] ) ); … … 2507 2495 $join .= $clauses['join']; 2508 2496 $where .= $clauses['where']; 2509 }2510 2511 // If *__in is passed to WP_Query as an empty array, don't return results2512 foreach ( array( 'category', 'tag', 'tag_slug' ) as $in ) {2513 if ( isset( $q["{$in}__in"] ) && false === $q["{$in}__in"] ) {2514 $where = " AND 1=0 $where";2515 }2516 2497 } 2517 2498 … … 2607 2588 $author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) ); 2608 2589 $where .= " AND {$wpdb->posts}.post_author IN ($author__in) "; 2609 } elseif ( isset( $this->query['author__in'] ) ) {2610 $author__in = 0;2611 $where .= ' AND 1=0 ';2612 2590 } 2613 2591 -
trunk/tests/phpunit/tests/query/results.php
r28664 r28783 403 403 } 404 404 405 /** 406 * @ticket 28099 407 */ 405 408 function test_empty_post__in() { 406 409 $posts1 = $this->q->query( array() ); 407 410 $this->assertNotEmpty( $posts1 ); 408 411 $posts2 = $this->q->query( array( 'post__in' => array() ) ); 409 $this->assert Empty( $posts2 );412 $this->assertNotEmpty( $posts2 ); 410 413 $posts3 = $this->q->query( array( 'post_parent__in' => array() ) ); 411 $this->assert Empty( $posts3 );414 $this->assertNotEmpty( $posts3 ); 412 415 } 413 416 … … 515 518 516 519 $posts = $this->q->query( array( 'author__in' => array() ) ); 517 $this->assert Empty( $posts );520 $this->assertNotEmpty( $posts ); 518 521 519 522 $posts = $this->q->query( array( -
trunk/tests/phpunit/tests/term/query.php
r28664 r28783 204 204 } 205 205 206 /** 207 * @ticket 28099 208 */ 206 209 function test_empty__in() { 207 210 $cat_id = $this->factory->category->create(); … … 212 215 $this->assertNotEmpty( $q1 ); 213 216 $q2 = get_posts( array( 'category__in' => array() ) ); 214 $this->assert Empty( $q2 );217 $this->assertNotEmpty( $q2 ); 215 218 216 219 $tag = wp_insert_term( 'woo', 'post_tag' ); … … 222 225 $this->assertNotEmpty( $q3 ); 223 226 $q4 = get_posts( array( 'tag__in' => array() ) ); 224 $this->assert Empty( $q4 );227 $this->assertNotEmpty( $q4 ); 225 228 226 229 $q5 = get_posts( array( 'tag_slug__in' => array( $slug ) ) ); 227 230 $this->assertNotEmpty( $q5 ); 228 231 $q6 = get_posts( array( 'tag_slug__in' => array() ) ); 229 $this->assert Empty( $q6 );232 $this->assertNotEmpty( $q6 ); 230 233 } 231 234 }
Note: See TracChangeset
for help on using the changeset viewer.