core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php | 7 +++++-- core/tests/Drupal/Tests/Core/Render/RendererTestBase.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php b/core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php index 7a43beb..3ecf35d 100644 --- a/core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php +++ b/core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php @@ -133,7 +133,9 @@ public function get(array $elements) { // rendered content (which it cannot and may not, because after all it was // uncacheable, due to that max-age = 0). // When not replacing placeholders, the above will ensure that this - // max-age=0 element is placeholdered. + // max-age=0 element is placeholdered. When replacing placeholders, this + // condition ensures this element is not placeholdered again, which would + // lead to endless recursion. if (isset($elements['#create_placeholder']) && $elements['#create_placeholder'] === FALSE && !$this->maxAgeAllowsCaching($cached_element)) { return FALSE; } @@ -163,7 +165,8 @@ public function set(array &$elements, array $pre_bubbling_elements) { // Cache #cache['max-age'] = 0! We just want to cache the cacheability. $data = ['#cache' => $elements['#cache'], '#markup' => '', '#attached' => []]; - // + // Override the expiration timestamp so that we can cache this max-age=0 + // element, which is normally not cacheable. $this->expireOverride = Cache::PERMANENT; parent::doSet($data, $pre_bubbling_elements); $this->expireOverride = NULL; diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php index af696ba..9b992f7 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php @@ -282,7 +282,7 @@ public static function callback($animal, $use_animal_as_array_key = FALSE) { * #lazy_builder callback; attaches setting, generates markup, max-age = 0. * * @param string $animal - * An animal. + * An animal. * * @return array * A renderable array.