Ticket #47719: 47719.3.diff
| File 47719.3.diff, 3.0 KB (added by , 12 months ago) |
|---|
-
src/wp-includes/class-wp-term-query.php
470 470 $exclude_tree = $args['exclude_tree']; 471 471 $include = $args['include']; 472 472 473 $inclusions = '';474 473 if ( ! empty( $include ) ) { 475 $exclude = ''; 476 $exclude_tree = ''; 477 $inclusions = implode( ',', wp_parse_id_list( $include ) ); 478 } 479 480 if ( ! empty( $inclusions ) ) { 474 $exclude = ''; 475 $exclude_tree = ''; 476 $inclusions = implode( ',', wp_parse_id_list( $include ) ); 481 477 $this->sql_clauses['where']['inclusions'] = 't.term_id IN ( ' . $inclusions . ' )'; 482 478 } 483 479 … … 814 810 $terms = $wpdb->get_results( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 815 811 816 812 if ( empty( $terms ) ) { 813 $this->terms = array(); 814 817 815 if ( $args['cache_results'] ) { 818 wp_cache_add( $cache_key, array(), 'term-queries' );816 wp_cache_add( $cache_key, $this->terms, 'term-queries' ); 819 817 } 820 return array(); 818 819 return $this->terms; 821 820 } 822 821 823 822 $term_ids = wp_list_pluck( $terms, 'term_id' ); -
tests/phpunit/tests/post/query.php
777 777 } 778 778 779 779 /** 780 * @ticket 47719 781 */ 782 public function test_post__in_should_return_no_posts_when_0() { 783 self::factory()->post->create_many( 4 ); 784 785 $query = new WP_Query( 786 array( 787 'post_type' => 'post', 788 'post__in' => array( 0 ), 789 ) 790 ); 791 792 $this->assertSame( array(), $query->posts ); 793 $this->assertSame( 0, $query->found_posts ); 794 } 795 796 /** 780 797 * @ticket 57296 781 798 * @covers WP_Query::get_posts 782 799 */ -
tests/phpunit/tests/term/query.php
1005 1005 } 1006 1006 1007 1007 /** 1008 * @ticket 47719 1009 */ 1010 public function test_include_should_return_no_terms_when_0() { 1011 register_taxonomy( 'wptests_tax', 'post' ); 1012 1013 self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 1014 1015 $query = new WP_Term_Query( 1016 array( 1017 'taxonomy' => 'wptests_tax', 1018 'include' => array( 0 ), 1019 ) 1020 ); 1021 1022 $expected = array(); 1023 $this->assertSame( $expected, $query->terms ); 1024 $this->assertSame( $expected, $query->get_terms() ); 1025 } 1026 1027 /** 1008 1028 * Ensure cache keys are generated without WPDB placeholders. 1009 1029 * 1010 1030 * @ticket 57298 -
tests/phpunit/tests/user/query.php
1740 1740 $this->assertSame( 1, $q->total_users ); 1741 1741 } 1742 1742 1743 /** 1744 * @ticket 47719 1745 */ 1746 public function test_include_should_return_no_users_when_0() { 1747 $query = new WP_User_Query( 1748 array( 1749 'role' => '', 1750 'include' => array( 0 ), 1751 ) 1752 ); 1753 1754 $this->assertSame( array(), $query->get_results() ); 1755 } 1756 1743 1757 public static function filter_users_pre_query( $posts, $query ) { 1744 1758 $query->total_users = 1; 1745 1759
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)