Make WordPress Core


Ignore:
Timestamp:
01/02/2017 07:58:09 PM (10 years ago)
Author:
boonebgorges
Message:

Ignore the 'comment_order' setting when determining comment pagination.

[38740] incorrectly introduced logic that changed a comment's page when
'comment_order' was set to 'desc'. This is in violation of the design
of the comment pagination system: a comment's page is designed not to
change when 'comment_order' or 'default_comment_page' are changed.
See #31101.

Props rachelbaker.
Fixes #39280.

File:
1 edited

Legend:

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

    r38740 r39663  
    242242        /**
    243243         * @ticket 31101
    244          */
    245         public function test_should_respect_comment_order_newest() {
     244         * @ticket 39280
     245         */
     246        public function test_should_ignore_comment_order() {
    246247                $now = time();
    247248
     
    250251                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
    251252                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
     253                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ) ) );
    252254
    253255                update_option( 'comment_order', 'desc' );
    254256                update_option( 'page_comments', 1 );
    255                 update_option( 'comments_per_page', 2 );
     257                update_option( 'comments_per_page', 1 );
    256258
    257259                $this->assertEquals( 2, get_page_of_comment( $c3 ) );
    258260        }
     261
     262        /**
     263         * @ticket 31101
     264         * @ticket 39280
     265         */
     266        public function test_should_ignore_default_comment_page() {
     267                $now = time();
     268
     269                $p = self::factory()->post->create();
     270                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
     271                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
     272                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
     273                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ) ) );
     274
     275                update_option( 'default_comment_page', 'newest' );
     276                update_option( 'page_comments', 1 );
     277                update_option( 'comments_per_page', 1 );
     278
     279                $this->assertEquals( 2, get_page_of_comment( $c3 ) );
     280        }
    259281}
Note: See TracChangeset for help on using the changeset viewer.