Make WordPress Core

Ticket #37696: 37696.2.diff

File 37696.2.diff, 2.4 KB (added by boonebgorges, 8 years ago)
  • src/wp-includes/class-wp-comment-query.php

    diff --git src/wp-includes/class-wp-comment-query.php src/wp-includes/class-wp-comment-query.php
    index 573115a..4643de1 100644
    class WP_Comment_Query { 
    998998                                $parent_query_args['parent__in']    = $uncached_parent_ids;
    999999                                $parent_query_args['no_found_rows'] = true;
    10001000                                $parent_query_args['hierarchical']  = false;
     1001                                $parent_query_args['offset']        = 0;
     1002                                $parent_query_args['number']        = 0;
    10011003
    10021004                                $level_comments = get_comments( $parent_query_args );
    10031005
  • tests/phpunit/tests/comment/query.php

    diff --git tests/phpunit/tests/comment/query.php tests/phpunit/tests/comment/query.php
    index 4710d64..ff4e3ac 100644
    class Tests_Comment_Query extends WP_UnitTestCase { 
    25442544        }
    25452545
    25462546        /**
     2547         * @ticket 37966
     2548         * @ticket 37696
     2549         */
     2550        public function test_fill_hierarchy_should_disregard_offset_and_number() {
     2551                $c0 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) );
     2552                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) );
     2553                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1 ) );
     2554                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) );
     2555                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c3 ) );
     2556                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c3 ) );
     2557
     2558                $q = new WP_Comment_Query();
     2559                $found = $q->query( array(
     2560                        'orderby' => 'comment_date_gmt',
     2561                        'order' => 'ASC',
     2562                        'status' => 'approve',
     2563                        'post_id' => self::$post_id,
     2564                        'no_found_rows' => false,
     2565                        'hierarchical' => 'threaded',
     2566                        'number' => 2,
     2567                        'offset' => 1,
     2568                ) );
     2569
     2570
     2571                $found_1 = $found[ $c1 ];
     2572                $children_1 = $found_1->get_children();
     2573                $this->assertEqualSets( array( $c2 ), array_keys( $children_1 ) );
     2574
     2575                $found_3 = $found[ $c3 ];
     2576                $children_3 = $found_3->get_children();
     2577                $this->assertEqualSets( array( $c4, $c5 ), array_keys( $children_3 ) );
     2578        }
     2579
     2580        /**
    25472581         * @ticket 27571
    25482582         */
    25492583        public function test_update_comment_post_cache_should_be_disabled_by_default() {