core/modules/comment/src/CommentViewBuilder.php | 5 ++++- .../FieldFormatter/EntityReferenceEntityFormatter.php | 1 + core/modules/filter/filter.module | 2 +- .../Plugin/Field/FieldFormatter/TextDefaultFormatter.php | 12 +++++++++++- .../Plugin/Field/FieldFormatter/TextTrimmedFormatter.php | 14 ++++++++++++-- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/core/modules/comment/src/CommentViewBuilder.php b/core/modules/comment/src/CommentViewBuilder.php index 7fbceb7..623e304 100644 --- a/core/modules/comment/src/CommentViewBuilder.php +++ b/core/modules/comment/src/CommentViewBuilder.php @@ -139,7 +139,10 @@ public function buildComponents(array &$build, array $entities, array $displays, '#format' => $account->getSignatureFormat(), '#langcode' => $entity->language()->getId(), ); - // @todo Document; similar to what we saw in https://drupal.org/node/2099131 + // The signature will only be rendered in the theme layer, which means + // its associated cache tags will not bubble up. Work around this for + // now by already rendering the signature here. + // @todo remove this work-around, see https://drupal.org/node/2273277 drupal_render($build[$id]['signature'], TRUE); } diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php index 410a256..4065ea2 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -106,6 +106,7 @@ public function viewElements(FieldItemListInterface $items) { // 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(). + // @todo remove this work-around, see https://drupal.org/node/2273277 $referenced_entity_build = entity_view($item->entity, $view_mode, $item->getLangcode()); drupal_render($referenced_entity_build, TRUE); $elements[$delta] = $referenced_entity_build; diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index ef15e48..5c0a4e2 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -219,7 +219,7 @@ function filter_pre_render_text(array $element) { } $element['#attached'] = NestedArray::mergeDeepArray($all_assets); - // Collect all #post_render_cahe callbacks. + // Collect all #post_render_cache callbacks. if (isset($element['#post_render_cache'])) { // Prepend the original attached #post_render_cache array. array_unshift($all_assets, $element['#post_render_cache']); diff --git a/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php b/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php index d570417..cfd83dc 100644 --- a/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php +++ b/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php @@ -60,7 +60,17 @@ protected function viewElementsWithTextProcessing(FieldItemListInterface $items) '#format' => $item->format, '#langcode' => $item->getLangcode(), ); - // @todo Document; similar to what we saw in https://drupal.org/node/2099131 + // 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 cache tags must be available after the #pre_render phase. In order + // to collect the cache tags associated with the processed text, it must + // be passed to drupal_render() so that its #pre_render callback is + // invoked and its full build array is assembled. Rendering the processed + // text 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(). + // @todo remove this work-around, see https://drupal.org/node/2273277 drupal_render($elements[$delta], TRUE); } diff --git a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php index b29ec1c..f2bbefc 100644 --- a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php +++ b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php @@ -97,14 +97,24 @@ protected function viewElementsWithTextProcessing(FieldItemListInterface $items) '#langcode' => $item->getLangcode(), ); + // 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 cache tags must be available after the #pre_render phase. In order + // to collect the cache tags associated with the processed text, it must + // be passed to drupal_render() so that its #pre_render callback is + // invoked and its full build array is assembled. Rendering the processed + // text 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(). if ($this->getPluginId() == 'text_summary_or_trimmed' && !empty($item->summary)) { $elements[$delta]['#text'] = $item->summary; - // @todo Document; similar to what we saw in https://drupal.org/node/2099131 + // @todo remove this work-around, see https://drupal.org/node/2273277 drupal_render($elements[$delta], TRUE); } else { $elements[$delta]['#text'] = $item->value; - // @todo Document; similar to what we saw in https://drupal.org/node/2099131 + // @todo remove this work-around, see https://drupal.org/node/2273277 drupal_render($elements[$delta], TRUE); $elements[$delta]['#markup'] = text_summary($elements[$delta]['#markup'], $item->format, $this->getSetting('trim_length')); }