diff --git a/wp-content/themes/default/comments.php b/wp-content/themes/default/comments.php
index 685b86d847..5b82b619c9 100644
--- a/wp-content/themes/default/comments.php
+++ b/wp-content/themes/default/comments.php
@@ -20,9 +20,15 @@
+
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index b2785db420..b034013ee7 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -513,6 +513,9 @@ function &separate_comments(&$comments) {
function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
global $wp_query;
+ if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
+ return $wp_query->max_num_comment_pages;
+
if ( !$comments || !is_array($comments) )
$comments = $wp_query->comments;
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index 6dce0c192f..1bbf845500 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -1265,6 +1265,9 @@ function next_comments_link($label='', $max_page = 0) {
if ( empty($max_page) )
$max_page = $wp_query->max_num_comment_pages;
+ if ( empty($max_page) )
+ $max_page = get_comment_pages_count();
+
if ( $nextpage > $max_page )
return;
@@ -1324,7 +1327,7 @@ function paginate_comments_links($args = array()) {
$page = get_query_var('cpage');
if ( !$page )
$page = 1;
- $max_page = $wp_query->max_num_comment_pages;
+ $max_page = get_comment_pages_count();
$defaults = array(
'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '',