Ignore hierarchy in pagination calculation when comment threading is disabled.

In order to calculate comment pagination when newest comments are displayed
first, `comments_template()` must perform a separate query to determine the
total number of paginating comments available on a post. See [34729], #8071,
pagination calculation - can be defined as a top-level comment, or a comment
with `parent=0`. However, when comment threading is disabled, yet comments
exist in the database that have parents, all comments - even those with a
parent - are "paginating". (This typically happens when comments threading was
once enabled, but has since been turned off.) As such, the total-paginating-
comments query should only be limited to top-level comments when
'thread_comments' is disabled.

Props jmdodd.
Fixes #35419.
Built from https://develop.svn.wordpress.org/trunk@36275


git-svn-id: http://core.svn.wordpress.org/trunk@36242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2016-01-13 03:13:25 +00:00
parent 5036a79e73
commit 294a164b15
2 changed files with 5 additions and 2 deletions

View File

@ -1323,10 +1323,13 @@ function comments_template( $file = '/comments.php', $separate_comments = false
'count' => true, 'count' => true,
'orderby' => false, 'orderby' => false,
'post_id' => $post->ID, 'post_id' => $post->ID,
'parent' => 0,
'status' => 'approve', 'status' => 'approve',
); );
if ( $comment_args['hierarchical'] ) {
$top_level_args['parent'] = 0;
}
if ( isset( $comment_args['include_unapproved'] ) ) { if ( isset( $comment_args['include_unapproved'] ) ) {
$top_level_args['include_unapproved'] = $comment_args['include_unapproved']; $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.5-alpha-36274'; $wp_version = '4.5-alpha-36275';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.