Ticket #42256: 42256.2.diff
| File 42256.2.diff, 1.5 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/class-wp-query.php
1917 1917 } elseif ( $q['post__in'] ) { 1918 1918 $post__in = implode(',', array_map( 'absint', $q['post__in'] )); 1919 1919 $where .= " AND {$wpdb->posts}.ID IN ($post__in)"; 1920 1921 // Don't count found rows when a specific range is requested. 1922 if ( isset( $q['posts_per_page'] ) && count( $q['post__in'] ) === (int) $q['posts_per_page'] ) { 1923 $q['no_found_rows'] = true; 1924 } 1920 1925 } elseif ( $q['post__not_in'] ) { 1921 1926 $post__not_in = implode(',', array_map( 'absint', $q['post__not_in'] )); 1922 1927 $where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)"; -
tests/phpunit/tests/query/noFoundRows.php
86 86 $this->assertNotContains( 'SQL_CALC_FOUND_ROWS', $q->request ); 87 87 $this->assertSame( 1, $q->found_posts ); 88 88 } 89 90 /** 91 * @ticket 42256 92 */ 93 public function test_no_found_rows_true_when_post__in_count_matches_posts_per_page() { 94 $post_ids = $this->factory->post->create_many( 3 ); 95 96 $q = new WP_Query( array( 97 'post__in' => $post_ids, 98 'posts_per_page' => count( $post_ids ), 99 ) ); 100 101 $this->assertNotContains( 'SQL_CALC_FOUND_ROWS', $q->request ); 102 } 89 103 }