diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 8930d76..4eeb5f8 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -11,6 +11,7 @@
  */
 
 use Drupal\comment\CommentInterface;
+use Drupal\comment\CommentManagerInterface;
 use Drupal\comment\Entity\Comment;
 use Drupal\comment\Entity\CommentType;
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
@@ -31,16 +32,6 @@
 use Drupal\node\NodeInterface;
 
 /**
- * Comments are displayed in a flat list - expanded.
- */
-const COMMENT_MODE_FLAT = 0;
-
-/**
- * Comments are displayed as a threaded list - expanded.
- */
-const COMMENT_MODE_THREADED = 1;
-
-/**
  * Anonymous posters cannot enter their contact information.
  */
 const COMMENT_ANONYMOUS_MAYNOT_CONTACT = 0;
@@ -244,81 +235,27 @@ function comment_permission() {
 /**
  * Calculates the page number for the first new comment.
  *
- * @param int $num_comments
- *   Number of comments.
- * @param int $new_replies
- *   Number of new replies.
+ * @param int $total_comments
+ *   The total number of comments that the entity has.
+ * @param int $new_comments
+ *   The number of new comments that the entity has.
  * @param \Drupal\Core\Entity\ContentEntityInterface $entity
- *   The first new comment entity.
+ *   The entity to which the comments belong.
  * @param string $field_name
- *   The field name on the entity to which comments are attached to.
+ *   The field name on the entity to which comments are attached.
  *
  * @return array|null
  *   An array "page=X" if the page number is greater than zero; NULL otherwise.
+ *
+ * @deprecated Deprecated since Drupal 8.x-dev, to be removed in Drupal 8.0.
+ *   Use \Drupal\comment\CommentStorageInterface::getNewCommentPageNumber();
+ *   Note this returns an integer instead of array|null.
  */
-function comment_new_page_count($num_comments, $new_replies, ContentEntityInterface $entity, $field_name = 'comment') {
-  $field_definition = $entity->getFieldDefinition($field_name);
-  $mode = $field_definition->getSetting('default_mode');
-  $comments_per_page = $field_definition->getSetting('per_page');
-  $pagenum = NULL;
-  $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE;
-  if ($num_comments <= $comments_per_page) {
-    // Only one page of comments.
-    $pageno = 0;
-  }
-  elseif ($flat) {
-    // Flat comments.
-    $count = $num_comments - $new_replies;
-    $pageno = $count / $comments_per_page;
-  }
-  else {
-    // Threaded comments: we build a query with a subquery to find the first
-    // thread with a new comment.
-
-    // 1. Find all the threads with a new comment.
-    $unread_threads_query = db_select('comment')
-      ->fields('comment', array('thread'))
-      ->condition('entity_id', $entity->id())
-      ->condition('entity_type', $entity->getEntityTypeId())
-      ->condition('field_name', $field_name)
-      ->condition('status', CommentInterface::PUBLISHED)
-      ->orderBy('created', 'DESC')
-      ->orderBy('cid', 'DESC')
-      ->range(0, $new_replies);
-
-    // 2. Find the first thread.
-    $first_thread_query = db_select($unread_threads_query, 'thread');
-    $first_thread_query->addExpression('SUBSTRING(thread, 1, (LENGTH(thread) - 1))', 'torder');
-    $first_thread = $first_thread_query
-      ->fields('thread', array('thread'))
-      ->orderBy('torder')
-      ->range(0, 1)
-      ->execute()
-      ->fetchField();
-
-    // Remove the final '/'.
-    $first_thread = substr($first_thread, 0, -1);
-
-    // Find the number of the first comment of the first unread thread.
-    $count = db_query('SELECT COUNT(*) FROM {comment} WHERE entity_id = :entity_id
-                      AND entity_type = :entity_type
-                      AND field_name = :field_name
-                      AND status = :status AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread', array(
-      ':status' => CommentInterface::PUBLISHED,
-      ':entity_id' => $entity->id(),
-      ':field_name' => $field_name,
-      ':entity_type' => $entity->getEntityTypeId(),
-      ':thread' => $first_thread,
-    ))->fetchField();
-
-    $pageno = $count / $comments_per_page;
-  }
-
-  if ($pageno >= 1) {
-    $pagenum = array('page' => intval($pageno));
-  }
+function comment_new_page_count($total_comments, $new_comments, ContentEntityInterface $entity, $field_name = 'comment') {
+  $page_number = \Drupal::entityManager()->getStorage('comment')
+    ->getNewCommentPageNumber($total_comments, $new_comments, $entity, $field_name);
 
-  return $pagenum;
+  return $page_number ? array('page' => $page_number) : NULL;
 }
 
 /**
@@ -638,7 +575,7 @@ function comment_get_thread(EntityInterface $entity, $field_name, $mode, $commen
     $query->condition('c.status', CommentInterface::PUBLISHED);
     $count_query->condition('c.status', CommentInterface::PUBLISHED);
   }
-  if ($mode == COMMENT_MODE_FLAT) {
+  if ($mode == CommentManagerInterface::COMMENT_MODE_FLAT) {
     $query->orderBy('c.cid', 'ASC');
   }
   else {
@@ -1112,7 +1049,7 @@ function comment_get_display_ordinal($cid, FieldDefinitionInterface $field_defin
     $query->condition('c1.status', CommentInterface::PUBLISHED);
   }
 
-  if ($field_definition->getSetting('default_mode') == COMMENT_MODE_FLAT) {
+  if ($field_definition->getSetting('default_mode') == CommentManagerInterface::COMMENT_MODE_FLAT) {
     // For flat comments, cid is used for ordering comments due to
     // unpredictable behavior with timestamp, so we make the same assumption
     // here.
diff --git a/core/modules/comment/src/CommentManagerInterface.php b/core/modules/comment/src/CommentManagerInterface.php
index 8797065..dcad1ae 100644
--- a/core/modules/comment/src/CommentManagerInterface.php
+++ b/core/modules/comment/src/CommentManagerInterface.php
@@ -16,6 +16,16 @@
 interface CommentManagerInterface {
 
   /**
+   * Comments are displayed in a flat list - expanded.
+   */
+  const COMMENT_MODE_FLAT = 0;
+
+  /**
+   * Comments are displayed as a threaded list - expanded.
+   */
+  const COMMENT_MODE_THREADED = 1;
+
+  /**
    * Utility function to return an array of comment fields.
    *
    * @param string $entity_type_id
diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php
index b56bb07..3e1aacb 100644
--- a/core/modules/comment/src/CommentStorage.php
+++ b/core/modules/comment/src/CommentStorage.php
@@ -8,7 +8,7 @@
 namespace Drupal\comment;
 
 use Drupal\Core\Database\Connection;
-use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Entity\ContentEntityInterface;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Entity\ContentEntityDatabaseStorage;
@@ -92,7 +92,7 @@ public function updateEntityStatistics(CommentInterface $comment) {
   /**
    * {@inheritdoc}
    */
-  public function getMaxThread(EntityInterface $comment) {
+  public function getMaxThread(CommentInterface $comment) {
     $query = $this->database->select('comment', 'c')
       ->condition('entity_id', $comment->getCommentedEntityId())
       ->condition('field_name', $comment->getFieldName())
@@ -105,7 +105,7 @@ public function getMaxThread(EntityInterface $comment) {
   /**
    * {@inheritdoc}
    */
-  public function getMaxThreadPerThread(EntityInterface $comment) {
+  public function getMaxThreadPerThread(CommentInterface $comment) {
     $query = $this->database->select('comment', 'c')
       ->condition('entity_id', $comment->getCommentedEntityId())
       ->condition('field_name', $comment->getFieldName())
@@ -119,6 +119,64 @@ public function getMaxThreadPerThread(EntityInterface $comment) {
   /**
    * {@inheritdoc}
    */
+  public function getNewCommentPageNumber($total_comments, $new_comments, ContentEntityInterface $entity, $field_name = 'comment') {
+    $instance = $entity->getFieldDefinition($field_name);
+    $comments_per_page = $instance->getSetting('per_page');
+
+    if ($total_comments <= $comments_per_page) {
+      // Only one page of comments.
+      $count = 0;
+    }
+    elseif ($instance->getSetting('default_mode') == CommentManagerInterface::COMMENT_MODE_FLAT) {
+      // Flat comments.
+      $count = $total_comments - $new_comments;
+    }
+    else {
+      // Threaded comments.
+
+      // 1. Find all the threads with a new comment.
+      $unread_threads_query = $this->database->select('comment')
+        ->fields('comment', array('thread'))
+        ->condition('entity_id', $entity->id())
+        ->condition('entity_type', $entity->getEntityTypeId())
+        ->condition('field_name', $field_name)
+        ->condition('status', CommentInterface::PUBLISHED)
+        ->orderBy('created', 'DESC')
+        ->orderBy('cid', 'DESC')
+        ->range(0, $new_comments);
+
+      // 2. Find the first thread.
+      $first_thread_query = $this->database->select($unread_threads_query, 'thread');
+      $first_thread_query->addExpression('SUBSTRING(thread, 1, (LENGTH(thread) - 1))', 'torder');
+      $first_thread = $first_thread_query
+        ->fields('thread', array('thread'))
+        ->orderBy('torder')
+        ->range(0, 1)
+        ->execute()
+        ->fetchField();
+
+      // Remove the final '/'.
+      $first_thread = substr($first_thread, 0, -1);
+
+      // Find the number of the first comment of the first unread thread.
+      $count = $this->database->query('SELECT COUNT(*) FROM {comment} WHERE entity_id = :entity_id
+                        AND entity_type = :entity_type
+                        AND field_name = :field_name
+                        AND status = :status AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread', array(
+        ':status' => CommentInterface::PUBLISHED,
+        ':entity_id' => $entity->id(),
+        ':field_name' => $field_name,
+        ':entity_type' => $entity->getEntityTypeId(),
+        ':thread' => $first_thread,
+      ))->fetchField();
+    }
+
+    return $comments_per_page > 0 ? (int) ($count / $comments_per_page) : 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public function getChildCids(array $comments) {
     return $this->database->select('comment', 'c')
       ->fields('c', array('cid'))
diff --git a/core/modules/comment/src/CommentStorageInterface.php b/core/modules/comment/src/CommentStorageInterface.php
index e1b4f62..f97663a 100644
--- a/core/modules/comment/src/CommentStorageInterface.php
+++ b/core/modules/comment/src/CommentStorageInterface.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\comment;
 
-use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Entity\ContentEntityInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
 
 /**
@@ -16,27 +16,44 @@
 interface CommentStorageInterface extends EntityStorageInterface {
 
   /**
-   * Get the maximum encoded thread value for the top level comments.
+   * Gets the maximum encoded thread value for the top level comments.
    *
-   * @param EntityInterface $comment
+   * @param \Drupal\comment\CommentInterface $comment
    *   A comment entity.
    *
    * @return string
    *   The maximum encoded thread value among the top level comments of the
    *   node $comment belongs to.
    */
-  public function getMaxThread(EntityInterface $comment);
+  public function getMaxThread(CommentInterface $comment);
 
   /**
-   * Get the maximum encoded thread value for the children of this comment.
+   * Gets the maximum encoded thread value for the children of this comment.
    *
-   * @param EntityInterface $comment
+   * @param \Drupal\comment\CommentInterface $comment
    *   A comment entity.
    *
    * @return string
    *   The maximum encoded thread value among all replies of $comment.
    */
-  public function getMaxThreadPerThread(EntityInterface $comment);
+  public function getMaxThreadPerThread(CommentInterface $comment);
+
+  /**
+   * Calculates the page number for the first new comment.
+   *
+   * @param int $total_comments
+   *   The total number of comments that the entity has.
+   * @param int $new_comments
+   *   The number of new comments that the entity has.
+   * @param \Drupal\Core\Entity\ContentEntityInterface $entity
+   *   The entity to which the comments belong.
+   * @param string $field_name
+   *   The field name on the entity to which comments are attached.
+   *
+   * @return array|null
+   *   An array "page=X" if the page number is greater than zero; NULL otherwise.
+   */
+  public function getNewCommentPageNumber($total_comments, $new_comments, ContentEntityInterface $entity, $field_name = 'comment');
 
   /**
    * Gets the comment ids of the passed comment entities' children.
diff --git a/core/modules/comment/src/CommentViewBuilder.php b/core/modules/comment/src/CommentViewBuilder.php
index b7cba52..9d46dfb 100644
--- a/core/modules/comment/src/CommentViewBuilder.php
+++ b/core/modules/comment/src/CommentViewBuilder.php
@@ -290,7 +290,7 @@ protected function alterBuild(array &$build, EntityInterface $comment, EntityVie
       $commented_entity = $comment->getCommentedEntity();
       $field_definition = $this->entityManager->getFieldDefinitions($commented_entity->getEntityTypeId(), $commented_entity->bundle())[$comment->getFieldName()];
       $is_threaded = isset($comment->divs)
-        && $field_definition->getSetting('default_mode') == COMMENT_MODE_THREADED;
+        && $field_definition->getSetting('default_mode') == CommentManagerInterface::COMMENT_MODE_THREADED;
 
       // Add indentation div or close open divs as needed.
       if ($is_threaded) {
@@ -336,7 +336,10 @@ public static function attachNewCommentsLinkMetadata(array $element, array $cont
       ->getStorage($context['entity_type'])
       ->load($context['entity_id']);
     $field_name = $context['field_name'];
-    $query = comment_new_page_count($entity->{$field_name}->comment_count, $new, $entity);
+    $page_number = \Drupal::entityManager()
+      ->getStorage('comment')
+      ->getNewCommentPageNumber($entity->{$field_name}->comment_count, $new, $entity);
+    $query = $page_number ? array('page' => $page_number) : NULL;
 
     // Attach metadata.
     $element['#attached']['js'][] = array(
diff --git a/core/modules/comment/src/Controller/CommentController.php b/core/modules/comment/src/Controller/CommentController.php
index 94fb25e..e224fe2 100644
--- a/core/modules/comment/src/Controller/CommentController.php
+++ b/core/modules/comment/src/Controller/CommentController.php
@@ -290,7 +290,9 @@ public function renderNewCommentsNodeLinks(Request $request) {
     foreach ($nids as $nid) {
       $node = node_load($nid);
       $new = comment_num_new($node->id(), 'node');
-      $query = comment_new_page_count($node->{$field_name}->comment_count, $new, $node);
+      $page_number = $this->entityManager()->getStorage('comment')
+        ->getNewCommentPageNumber($node->{$field_name}->comment_count, $new, $node);
+      $query = $page_number ? array('page' => $page_number) : NULL;
       $links[$nid] = array(
         'new_comment_count' => (int) $new,
         'first_new_comment_link' => $this->urlGenerator()->generateFromPath('node/' . $node->id(), array('query' => $query, 'fragment' => 'new')),
diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
index 7fb70aa..76fd9b9 100644
--- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
+++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\comment\Plugin\Field\FieldType;
 
+use Drupal\comment\CommentManagerInterface;
 use Drupal\comment\Entity\CommentType;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\TypedData\DataDefinition;
@@ -40,7 +41,7 @@ public static function defaultSettings() {
    */
   public static function defaultInstanceSettings() {
     return array(
-      'default_mode' => COMMENT_MODE_THREADED,
+      'default_mode' => CommentManagerInterface::COMMENT_MODE_THREADED,
       'per_page' => 50,
       'form_location' => COMMENT_FORM_BELOW,
       'anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT,
diff --git a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
index 5ccf4e2..495b175 100644
--- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
+++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
@@ -151,9 +151,11 @@ protected function renderLink($data, ResultRow $values) {
         'nid' => $this->getValue($values, 'nid'),
         'type' => $this->getValue($values, 'type'),
       ));
+      $page_number = \Drupal::entityManager()->getStorage('comment')
+        ->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node);
       $this->options['alter']['make_link'] = TRUE;
       $this->options['alter']['path'] = 'node/' . $node->id();
-      $this->options['alter']['query'] = comment_new_page_count($this->getValue($values, 'comment_count'), $this->getValue($values), $node);
+      $this->options['alter']['query'] = $page_number ? array('page' => $page_number) : NULL;
       $this->options['alter']['fragment'] = 'new';
     }
 
diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php
index 42157e1..40f77f6 100644
--- a/core/modules/comment/src/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\comment\Tests;
 
 use Drupal\comment\CommentInterface;
+use Drupal\comment\CommentManagerInterface;
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
 
 /**
@@ -32,7 +33,7 @@ function testCommentInterface() {
     $this->setCommentPreview(DRUPAL_DISABLED);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(FALSE);
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
     $this->drupalLogout();
 
     // Post comment #1 without subject or preview.
diff --git a/core/modules/comment/src/Tests/CommentNodeAccessTest.php b/core/modules/comment/src/Tests/CommentNodeAccessTest.php
index a3eba40..7e4525c 100644
--- a/core/modules/comment/src/Tests/CommentNodeAccessTest.php
+++ b/core/modules/comment/src/Tests/CommentNodeAccessTest.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\comment\Tests;
 
+use Drupal\comment\CommentManagerInterface;
+use Drupal\comment\Entity\Comment;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -60,7 +62,7 @@ function testThreadedCommentView() {
     $this->setCommentPreview(DRUPAL_DISABLED);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
     $this->drupalLogout();
 
     // Post comment.
diff --git a/core/modules/comment/src/Tests/CommentPagerTest.php b/core/modules/comment/src/Tests/CommentPagerTest.php
index f712ce0..b2f1865 100644
--- a/core/modules/comment/src/Tests/CommentPagerTest.php
+++ b/core/modules/comment/src/Tests/CommentPagerTest.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\comment\Tests;
+use Drupal\comment\CommentManagerInterface;
 
 /**
  * Verifies pagination of comments.
@@ -37,7 +38,7 @@ function testCommentPaging() {
     $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
     $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
 
-    $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
 
     // Set comments to one per page so that we are able to test paging without
     // needing to insert large numbers of comments.
@@ -77,7 +78,7 @@ function testCommentPaging() {
     // If we switch to threaded mode, the replies on the oldest comment
     // should be bumped to the first page and comment 6 should be bumped
     // to the second page.
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.');
     $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0)));
     $this->assertTrue($this->commentExists($reply, TRUE), 'In threaded mode, reply appears on page 1.');
     $this->assertFalse($this->commentExists($comments[1]), 'In threaded mode, comment 2 has been bumped off of page 1.');
@@ -137,7 +138,7 @@ function testCommentOrderingThreading() {
     // - 2
     //   - 5
 
-    $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
 
     $expected_order = array(
       0,
@@ -151,7 +152,7 @@ function testCommentOrderingThreading() {
     $this->drupalGet('node/' . $node->id());
     $this->assertCommentOrder($comments, $expected_order);
 
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.');
 
     $expected_order = array(
       0,
@@ -232,7 +233,7 @@ function testCommentNewPageIndicator() {
     // - 2
     //   - 5
 
-    $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
 
     $expected_pages = array(
       1 => 5, // Page of comment 5
@@ -245,12 +246,12 @@ function testCommentNewPageIndicator() {
 
     $node = node_load($node->id());
     foreach ($expected_pages as $new_replies => $expected_page) {
-      $returned = comment_new_page_count($node->get('comment')->comment_count, $new_replies, $node);
-      $returned_page = is_array($returned) ? $returned['page'] : 0;
+      $returned_page = \Drupal::entityManager()->getStorage('comment')
+        ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node);
       $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
     }
 
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.');
 
     $expected_pages = array(
       1 => 5, // Page of comment 5
@@ -264,8 +265,8 @@ function testCommentNewPageIndicator() {
     \Drupal::entityManager()->getStorage('node')->resetCache(array($node->id()));
     $node = node_load($node->id());
     foreach ($expected_pages as $new_replies => $expected_page) {
-      $returned = comment_new_page_count($node->get('comment')->comment_count, $new_replies, $node);
-      $returned_page = is_array($returned) ? $returned['page'] : 0;
+      $returned_page = \Drupal::entityManager()->getStorage('comment')
+        ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node);
       $this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
     }
   }
@@ -313,7 +314,7 @@ function testTwoPagers() {
       $this->setCommentForm(TRUE, $field_name);
       $this->setCommentSubject(TRUE, $field_name);
       $this->setCommentPreview(DRUPAL_OPTIONAL, $field_name);
-      $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.', $field_name);
+      $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.', $field_name);
 
       // Set comments to one per page so that we are able to test paging without
       // needing to insert large numbers of comments.
diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/src/Tests/CommentPreviewTest.php
index 1de62da..be76ccf 100644
--- a/core/modules/comment/src/Tests/CommentPreviewTest.php
+++ b/core/modules/comment/src/Tests/CommentPreviewTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\comment\Tests;
 
+use Drupal\comment\CommentManagerInterface;
 use Drupal\Core\Datetime\DrupalDateTime;
 
 /**
@@ -40,7 +41,7 @@ function testCommentPreview() {
     $this->setCommentPreview(DRUPAL_OPTIONAL);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
     $this->drupalLogout();
 
     // Login as web user and add a signature and a user picture.
@@ -83,7 +84,7 @@ function testCommentEditPreviewSave() {
     $this->setCommentPreview(DRUPAL_OPTIONAL);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
 
     $edit = array();
     $date = new DrupalDateTime('2008-03-02 17:23');
diff --git a/core/modules/comment/src/Tests/CommentStatisticsTest.php b/core/modules/comment/src/Tests/CommentStatisticsTest.php
index 6906b55..7172298 100644
--- a/core/modules/comment/src/Tests/CommentStatisticsTest.php
+++ b/core/modules/comment/src/Tests/CommentStatisticsTest.php
@@ -6,6 +6,8 @@
  */
 
 namespace Drupal\comment\Tests;
+use Drupal\comment\CommentManagerInterface;
+use Drupal\comment\Entity\Comment;
 
 /**
  * Tests the comment module administrative and end-user-facing interfaces.
@@ -44,7 +46,7 @@ function testCommentNodeCommentStatistics() {
     $this->setCommentPreview(DRUPAL_DISABLED);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(FALSE);
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
     $this->drupalLogout();
 
     // Checks the initial values of node comment statistics with no comment.
diff --git a/core/modules/comment/src/Tests/CommentThreadingTest.php b/core/modules/comment/src/Tests/CommentThreadingTest.php
index f0d7703..6656dc3 100644
--- a/core/modules/comment/src/Tests/CommentThreadingTest.php
+++ b/core/modules/comment/src/Tests/CommentThreadingTest.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\comment\Tests;
 
+use Drupal\comment\CommentManagerInterface;
+
 /**
  * Tests comment threading.
  */
@@ -28,7 +30,7 @@ function testCommentThreading() {
     $this->setCommentPreview(DRUPAL_DISABLED);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
-    $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
+    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
     $this->drupalLogout();
 
     // Create a node.
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index b0e9763..3a86279 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -590,8 +590,11 @@ function template_preprocess_forums(&$variables) {
         $variables['topics'][$id]->new_url = '';
 
         if ($topic->new_replies) {
+          $page_number = \Drupal::entityManager()->getStorage('comment')
+            ->getNewCommentPageNumber($topic->comment_count, $topic->new_replies, $topic, 'comment_node_forum');
+          $query = $page_number ? array('page' => $page_number) : NULL;
           $variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new post<span class="visually-hidden"> in topic %title</span>', '@count new posts<span class="visually-hidden"> in topic %title</span>', array('%title' => $variables['topics'][$id]->label()));
-          $variables['topics'][$id]->new_url = url('node/' . $topic->id(), array('query' => comment_new_page_count($topic->comment_count, $topic->new_replies, $topic, 'comment_node_forum'), 'fragment' => 'new'));
+          $variables['topics'][$id]->new_url = url('node/' . $topic->id(), array('query' => $query, 'fragment' => 'new'));
         }
 
         // Build table rows from topics.
diff --git a/core/modules/rdf/src/Tests/CommentAttributesTest.php b/core/modules/rdf/src/Tests/CommentAttributesTest.php
index d58e44b..d47d1ff 100644
--- a/core/modules/rdf/src/Tests/CommentAttributesTest.php
+++ b/core/modules/rdf/src/Tests/CommentAttributesTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\rdf\Tests;
 
 use Drupal\comment\CommentInterface;
+use Drupal\comment\CommentManagerInterface;
 use Drupal\comment\Tests\CommentTestBase;
 
 /**
@@ -44,7 +45,7 @@ public function setUp() {
     $this->setCommentPreview(DRUPAL_OPTIONAL);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
-    $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
+    $this->setCommentSettings('comment_default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
 
     // Prepares commonly used URIs.
     $this->base_uri = url('<front>', array('absolute' => TRUE));
