Make WordPress Core

Changeset 39664


Ignore:
Timestamp:
01/02/2017 08:06:59 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.

Merges [39663] to the 4.7 branch.

Props rachelbaker.
Fixes #39280.

Location:
branches/4.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/comment.php

    r39641 r39664  
    10041004                        return get_page_of_comment( $comment->comment_parent, $args );
    10051005
    1006                 if ( 'desc' === get_option( 'comment_order' ) ) {
    1007                         $compare = 'after';
    1008                 } else {
    1009                         $compare = 'before';
    1010                 }
    1011 
    10121006                $comment_args = array(
    10131007                        'type'       => $args['type'],
     
    10201014                                array(
    10211015                                        'column' => "$wpdb->comments.comment_date_gmt",
    1022                                         $compare => $comment->comment_date_gmt,
     1016                                        'before' => $comment->comment_date_gmt,
    10231017                                )
    10241018                        ),
  • branches/4.7/tests/phpunit/tests/comment/getPageOfComment.php

    r38740 r39664  
    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.