mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@39663 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -241,18 +241,40 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 31101
|
||||
* @ticket 39280
|
||||
*/
|
||||
public function test_should_respect_comment_order_newest() {
|
||||
public function test_should_ignore_comment_order() {
|
||||
$now = time();
|
||||
|
||||
$p = self::factory()->post->create();
|
||||
$c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
|
||||
$c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
|
||||
$c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
|
||||
$c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ) ) );
|
||||
|
||||
update_option( 'comment_order', 'desc' );
|
||||
update_option( 'page_comments', 1 );
|
||||
update_option( 'comments_per_page', 2 );
|
||||
update_option( 'comments_per_page', 1 );
|
||||
|
||||
$this->assertEquals( 2, get_page_of_comment( $c3 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 31101
|
||||
* @ticket 39280
|
||||
*/
|
||||
public function test_should_ignore_default_comment_page() {
|
||||
$now = time();
|
||||
|
||||
$p = self::factory()->post->create();
|
||||
$c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
|
||||
$c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
|
||||
$c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
|
||||
$c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ) ) );
|
||||
|
||||
update_option( 'default_comment_page', 'newest' );
|
||||
update_option( 'page_comments', 1 );
|
||||
update_option( 'comments_per_page', 1 );
|
||||
|
||||
$this->assertEquals( 2, get_page_of_comment( $c3 ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user