diff -u b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php --- b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -145,20 +145,6 @@ if ($this->getSetting('pager_id')) { $build['pager']['#element'] = $this->getSetting('pager_id'); } - // The viewElements() method of entity field formatters is run - // during the #pre_render phase of rendering an entity. A formatter - // builds the content of the field in preparation for theming. - // All entity cache tags must be available after the #pre_render phase. - // This field formatter is highly exceptional: it renders *another* - // entity and this referenced entity has its own #pre_render - // callbacks. In order collect the cache tags associated with the - // referenced entity it must be passed to drupal_render() so that its - // #pre_render callbacks are invoked and its full build array is - // assembled. Rendering the referenced entity in place here will allow - // its cache tags to be bubbled up and included with those of the - // main entity when cache tags are collected for a renderable array - // in drupal_render(). - drupal_render($build, TRUE); $output['comments'] = $build; } } diff -u b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php --- b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -93,22 +93,7 @@ } if (!empty($item->target_id)) { - // The viewElements() method of entity field formatters is run - // during the #pre_render phase of rendering an entity. A formatter - // builds the content of the field in preparation for theming. - // All entity cache tags must be available after the #pre_render phase. - // This field formatter is highly exceptional: it renders *another* - // entity and this referenced entity has its own #pre_render - // callbacks. In order collect the cache tags associated with the - // referenced entity it must be passed to drupal_render() so that its - // #pre_render callbacks are invoked and its full build array is - // assembled. Rendering the referenced entity in place here will allow - // its cache tags to be bubbled up and included with those of the - // main entity when cache tags are collected for a renderable array - // in drupal_render(). - $referenced_entity_build = entity_view($item->entity, $view_mode, $item->getLangcode()); - drupal_render($referenced_entity_build, TRUE); - $elements[$delta] = $referenced_entity_build; + $elements[$delta] = entity_view($item->entity, $view_mode, $item->getLangcode()); if (empty($links) && isset($result[$delta][$target_type][$item->target_id]['links'])) { // Hide the element links.