core/lib/Drupal/Core/Cache/CacheableResponseTrait.php | 7 ++++++- core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/CacheableResponseTrait.php b/core/lib/Drupal/Core/Cache/CacheableResponseTrait.php index 5b738c4..cda2f1d 100644 --- a/core/lib/Drupal/Core/Cache/CacheableResponseTrait.php +++ b/core/lib/Drupal/Core/Cache/CacheableResponseTrait.php @@ -22,7 +22,12 @@ public function addDependency($dependency) { $this->cacheabilityMetadata = new CacheableMetadata(); } - $this->cacheabilityMetadata = $this->cacheabilityMetadata->merge(CacheableMetadata::createFromObject($dependency)); + if (is_array($dependency)) { + $this->cacheabilityMetadata = $this->cacheabilityMetadata->merge(CacheableMetadata::createFromRenderArray($dependency)); + } + else { + $this->cacheabilityMetadata = $this->cacheabilityMetadata->merge(CacheableMetadata::createFromObject($dependency)); + } } /** diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php index 3321ba0..45ce3d0 100644 --- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php @@ -164,7 +164,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // arrays to the response. foreach (['page_top', 'page', 'page_bottom'] as $region) { if (isset($html[$region])) { - $response->addDependency(CacheableMetadata::createFromRenderArray($html[$region])); + $response->addDependency($html[$region]); } }