diff -u b/core/modules/comment/src/CommentViewBuilder.php b/core/modules/comment/src/CommentViewBuilder.php --- b/core/modules/comment/src/CommentViewBuilder.php +++ b/core/modules/comment/src/CommentViewBuilder.php @@ -82,7 +82,7 @@ // Store a threading field setting to use later in self::buildComponents(). $commented_entity = $entity->getCommentedEntity(); $build['#comment_threaded'] = - !$commented_entity + is_null($commented_entity) || $commented_entity->getFieldDefinition($entity->getFieldName()) ->getSetting('default_mode') === CommentManagerInterface::COMMENT_MODE_THREADED; // If threading is enabled, don't render cache individual comments, but do @@ -144,7 +144,7 @@ $commented_entity = $entity->getCommentedEntity(); // Set defaults if the commented_entity does not exist. $bundle = $commented_entity ? $commented_entity->bundle() : ''; - $entity_type_id = $commented_entity ? $commented_entity->getEntityTypeId() === 'node' : NULL; + $is_node = $commented_entity ? $commented_entity->getEntityTypeId() === 'node' : NULL; $build[$id]['#entity'] = $entity; $build[$id]['#theme'] = 'comment__' . $entity->getFieldName() . '__' . $bundle; @@ -168,7 +168,7 @@ $build[$id]['#attached'] = []; } $build[$id]['#attached']['library'][] = 'comment/drupal.comment-by-viewer'; - if ($attach_history && $entity_type_id) { + if ($attach_history && $is_node) { $build[$id]['#attached']['library'][] = 'comment/drupal.comment-new-indicator'; // Embed the metadata for the comment "new" indicators on this node. diff -u b/core/modules/comment/tests/src/Functional/CommentOrphanedTest.php b/core/modules/comment/tests/src/Functional/CommentOrphanedTest.php --- b/core/modules/comment/tests/src/Functional/CommentOrphanedTest.php +++ b/core/modules/comment/tests/src/Functional/CommentOrphanedTest.php @@ -51,7 +51,7 @@ $ids = [1, 2]; $entities = $comment_storage->loadMultiple($ids); foreach ($entities as $entity) { - $built = $this->buildEntityView($entity, 'full', NULL, TRUE); + $built = $this->buildEntityView($entity, 'full', NULL); $renderer->renderPlain($built); } @@ -72,7 +72,7 @@ $ids = [1, 2]; $entities = $comment_storage->loadMultiple($ids); foreach ($entities as $entity) { - $built = $this->buildEntityView($entity, 'full', NULL, TRUE); + $built = $this->buildEntityView($entity, 'full', NULL); $renderer->renderPlain($built); } reverted: --- b/core/tests/Drupal/Tests/EntityViewTrait.php +++ a/core/tests/Drupal/Tests/EntityViewTrait.php @@ -61,7 +61,7 @@ $render_controller = $this->container->get('entity_type.manager')->getViewBuilder($entity->getEntityTypeId()); if ($reset) { + $render_controller->resetCache([$entity->id()]); - $render_controller->resetCache([$entity]); } $build = $render_controller->view($entity, $view_mode, $langcode); $ensure_fully_built($build);