diff -u b/core/modules/comment/comment.module b/core/modules/comment/comment.module --- b/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1231,10 +1231,25 @@ $parent = $comment->getParentComment(); if ($parent && $parent->isPublished()) { $build = comment_view($parent); - $preview_build['comment_output_below'] = $build; } } + else { + // The comment field output includes rendering the parent entity of the + // thread to which the comment is a reply. The rendered entity output + // includes the comment reply form, which contains the comment preview and + // therefore the rendered parent entity. This results in an infinite loop of + // parent entity output rendering the comment form and the comment form + // rendering the parent entity. To prevent this infinite loop we temporarily + // set the value of the comment field on a clone of the entity to hidden + // before calling entity_view(). That way when the output of the commented + // entity is rendered, it excludes the comment field output. + $field_name = $comment->getFieldName(); + $entity = clone $entity; + $entity->$field_name->status = CommentItemInterface::HIDDEN; + $build = entity_view($entity, 'full'); + } + $preview_build['comment_output_below'] = $build; $preview_build['comment_output_below']['#weight'] = 100; return $preview_build; diff -u b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php --- b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -246,6 +246,17 @@ // Display the parent comment. $build['comment_parent'] = $this->entityManager()->getViewBuilder('comment')->view($comment); } + + // The comment is in response to a entity. + elseif ($entity->access('view', $account)) { + // We make sure the field value isn't set so we don't end up with a + // redirect loop. + $entity = clone $entity; + $entity->{$field_name}->status = CommentItemInterface::HIDDEN; + // Render array of the entity full view mode. + $build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->getEntityTypeId())->view($entity, 'full'); + unset($build['commented_entity']['#cache']); + } } else { $build['#title'] = $this->t('Preview comment'); reverted: --- b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php +++ a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php @@ -59,6 +59,9 @@ $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; $this->assertEqual(current($this->xpath($xpath)), $node->label(), 'Node breadcrumb is equal to node title.', 'Node'); + // Test node title in comment preview. + $this->assertEqual(current($this->xpath('//article[@id=:id]/h2/a/span', array(':id' => 'node-' . $node->id()))), $node->label(), 'Node preview title is equal to node title.', 'Node'); + // Test node title is clickable on teaser list (/node). $this->drupalGet('node'); $this->clickLink($node->label());