only in patch2: unchanged: --- a/core/modules/comment/src/CommentStorage.php +++ b/core/modules/comment/src/CommentStorage.php @@ -135,7 +135,7 @@ public function getDisplayOrdinal(CommentInterface $comment, $comment_mode, $div /** * {@inheritdoc} */ - public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name = 'comment') { + public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name) { $field = $entity->getFieldDefinition($field_name); $comments_per_page = $field->getSetting('per_page'); only in patch2: unchanged: --- a/core/modules/comment/src/CommentStorageInterface.php +++ b/core/modules/comment/src/CommentStorageInterface.php @@ -54,7 +54,7 @@ public function getMaxThreadPerThread(CommentInterface $comment); * @return array|null * The page number where first new comment appears. (First page returns 0.) */ - public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name = 'comment'); + public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name); /** * Gets the display ordinal or page number for a comment. only in patch2: unchanged: --- a/core/modules/comment/src/Controller/CommentController.php +++ b/core/modules/comment/src/Controller/CommentController.php @@ -335,7 +335,7 @@ public function renderNewCommentsNodeLinks(Request $request) { $node = $this->entityManager->getStorage('node')->load($nid); $new = $this->commentManager->getCountNewComments($node); $page_number = $this->entityManager()->getStorage('comment') - ->getNewCommentPageNumber($node->{$field_name}->comment_count, $new, $node); + ->getNewCommentPageNumber($node->{$field_name}->comment_count, $new, $node, $field_name); $query = $page_number ? array('page' => $page_number) : NULL; $links[$nid] = array( 'new_comment_count' => (int) $new, only in patch2: unchanged: --- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php @@ -161,12 +161,25 @@ public function preRender(&$values) { */ protected function renderLink($data, ResultRow $values) { if (!empty($this->options['link_to_comment']) && $data !== NULL && $data !== '') { + $node_type = $this->getValue($values, 'type'); $node = entity_create('node', array( 'nid' => $this->getValue($values, 'nid'), - 'type' => $this->getValue($values, 'type'), + 'type' => $node_type, )); - $page_number = \Drupal::entityManager()->getStorage('comment') - ->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node); + // Identify the "first" comment field available. + $entity_manager = \Drupal::entityManager(); + $field_map = $entity_manager->getFieldMapByFieldType('comment'); + $comment_field_name = 'comment'; + foreach ($field_map['node'] as $field_name => $field_data) { + foreach ($field_data['bundles'] as $bundle_name) { + if ($node_type == $bundle_name) { + $comment_field_name = $field_name; + break 2; + } + } + } + $page_number = $entity_manager->getStorage('comment') + ->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node, $comment_field_name); $this->options['alter']['make_link'] = TRUE; $this->options['alter']['url'] = $node->urlInfo(); $this->options['alter']['query'] = $page_number ? array('page' => $page_number) : NULL; only in patch2: unchanged: --- a/core/modules/comment/src/Tests/CommentPagerTest.php +++ b/core/modules/comment/src/Tests/CommentPagerTest.php @@ -250,7 +250,7 @@ function testCommentNewPageIndicator() { $node = Node::load($node->id()); foreach ($expected_pages as $new_replies => $expected_page) { $returned_page = \Drupal::entityManager()->getStorage('comment') - ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node); + ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment'); $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))); } @@ -269,7 +269,7 @@ function testCommentNewPageIndicator() { $node = Node::load($node->id()); foreach ($expected_pages as $new_replies => $expected_page) { $returned_page = \Drupal::entityManager()->getStorage('comment') - ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node); + ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment'); $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))); } }