Make WordPress Core


Ignore:
Timestamp:
10/03/2015 07:15:55 PM (9 years ago)
Author:
boonebgorges
Message:

Only count top-level comments when calculating threaded pagination.

The change in [34535] did not properly account for threading.

See #13939, #11334.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/getPageOfComment.php

    r34660 r34805  
    192192        $this->assertEquals( 2, $found_1 );
    193193    }
     194
     195    /**
     196     * @ticket 13939
     197     */
     198    public function test_only_top_level_comments_should_be_included_in_older_count() {
     199        $post = $this->factory->post->create();
     200
     201        $now = time();
     202        $comment_parents = $comment_children = array();
     203        for ( $i = 0; $i < 5; $i++ ) {
     204            $parent = $this->factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
     205            $comment_parents[ $i ] = $parent;
     206
     207            $child = $this->factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) );
     208            $comment_children[ $i ] = $child;
     209        }
     210
     211        $page_1_indicies = array( 2, 3, 4 );
     212        $page_2_indicies = array( 0, 1 );
     213
     214        $args = array(
     215            'per_page' => 3,
     216            'max_depth' => 2,
     217        );
     218
     219        foreach ( $page_1_indicies as $p1i ) {
     220            $this->assertSame( 1, (int) get_page_of_comment( $comment_parents[ $p1i ], $args ) );
     221            $this->assertSame( 1, (int) get_page_of_comment( $comment_children[ $p1i ], $args ) );
     222        }
     223
     224        foreach ( $page_2_indicies as $p2i ) {
     225            $this->assertSame( 2, (int) get_page_of_comment( $comment_parents[ $p2i ], $args ) );
     226            $this->assertSame( 2, (int) get_page_of_comment( $comment_children[ $p2i ], $args ) );
     227        }
     228    }
    194229}
Note: See TracChangeset for help on using the changeset viewer.