Use correct 'page_id' parameter in get_page_of_comment().

See #34057.

git-svn-id: https://develop.svn.wordpress.org/trunk@34660 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2015-09-28 15:09:34 +00:00
parent 6d87c4cecb
commit 05e0a3b97e
2 changed files with 21 additions and 1 deletions

View File

@ -877,7 +877,7 @@ function get_page_of_comment( $comment_ID, $args = array() ) {
$comment_args = array(
'type' => $args['type'],
'post_ID' => $comment->comment_post_ID,
'post_id' => $comment->comment_post_ID,
'fields' => 'ids',
'status' => 'approve',
'date_query' => array(

View File

@ -171,4 +171,24 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$this->assertEquals( 2, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) );
}
/**
* @ticket 34057
*/
public function test_query_should_be_limited_to_comments_on_the_proper_post() {
$posts = $this->factory->post->create_many( 2 );
$now = time();
$comments_0 = $comments_1 = array();
for ( $i = 0; $i < 5; $i++ ) {
$comments_0[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
$comments_1[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
}
$found_0 = get_page_of_comment( $comments_0[0], array( 'per_page' => 2 ) );
$this->assertEquals( 3, $found_0 );
$found_1 = get_page_of_comment( $comments_1[1], array( 'per_page' => 2 ) );
$this->assertEquals( 2, $found_1 );
}
}