Ticket #41826: 41826.2.patch
File 41826.2.patch, 1.8 KB (added by , 7 years ago) |
---|
-
src/wp-includes/class-wp-comment-query.php
632 632 633 633 $number = absint( $this->query_vars['number'] ); 634 634 $offset = absint( $this->query_vars['offset'] ); 635 $paged = absint( $this->query_vars['paged'] );635 $paged = absint( $this->query_vars['paged'] ); 636 636 637 if ( ! empty( $number ) ) { 638 if ( $offset ) { 639 $limits = 'LIMIT ' . $offset . ',' . $number; 637 // Limit 638 if ( $number > 0 ) { 639 if ( $offset > 0 ) { 640 $calc_offset = $offset; 641 } elseif( $paged > 0 ) { 642 $calc_offset = $number * ( $paged - 1 ); 640 643 } else { 641 $ limits = 'LIMIT ' . ( $number * ( $paged - 1 ) ) . ',' . $number;644 $calc_offset = 0; 642 645 } 646 $limits = $wpdb->prepare( "LIMIT %d, %d", $calc_offset, $number ); 643 647 } 644 648 649 650 645 651 if ( $this->query_vars['count'] ) { 646 652 $fields = 'COUNT(*)'; 647 653 } else { -
tests/phpunit/tests/comment/query.php
1635 1635 $this->assertSame( $expected, $found ); 1636 1636 } 1637 1637 1638 /** 1639 * @ticket 41826 1640 */ 1641 public function test_paged_zero_should_be_same_as_paged_one() { 1642 1643 $query0 = new WP_Comment_Query(); 1644 $found0 = $query0->query( array( 1645 'paged' => 0, 1646 'number' => 2, 1647 ) ); 1648 1649 $query1 = new WP_Comment_Query(); 1650 $found1 = $query1->query( array( 1651 'paged' => 1, 1652 'number' => 2, 1653 ) ); 1654 1655 $this->assertSame( $query0->request, $query1->request ); 1656 } 1657 1638 1658 public function test_post_type_single_value() { 1639 1659 register_post_type( 'post-type-1' ); 1640 1660 register_post_type( 'post-type-2' );