core/lib/Drupal/Core/Cache/CacheableMetadata.php | 6 +++--- core/lib/Drupal/Core/Render/BubbleableMetadata.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/CacheableMetadata.php b/core/lib/Drupal/Core/Cache/CacheableMetadata.php index 97cb14a..6261dc5 100644 --- a/core/lib/Drupal/Core/Cache/CacheableMetadata.php +++ b/core/lib/Drupal/Core/Cache/CacheableMetadata.php @@ -140,9 +140,9 @@ public function setCacheMaxAge($max_age) { */ public function merge(CacheableMetadata $other) { $result = new static(); - $result->contexts = empty($this->contexts) ? $other->contexts : Cache::mergeContexts($this->contexts, $other->contexts); - $result->tags = empty($this->tags) ? $other->tags : Cache::mergeTags($this->tags, $other->tags); - $result->maxAge = $this->maxAge === Cache::PERMANENT ? $other->maxAge : Cache::mergeMaxAges($this->maxAge, $other->maxAge); + $result->contexts = empty($this->contexts) ? $other->contexts : (empty($other->contexts) ? $this->contexts : Cache::mergeContexts($this->contexts, $other->contexts)); + $result->tags = empty($this->tags) ? $other->tags : (empty($other->tags) ? $this->tags : Cache::mergeTags($this->tags, $other->tags)); + $result->maxAge = $this->maxAge === Cache::PERMANENT ? $other->maxAge : ($other->maxAge === Cache::PERMANENT ? $this->maxAge : Cache::mergeMaxAges($this->maxAge, $other->maxAge)); return $result; } diff --git a/core/lib/Drupal/Core/Render/BubbleableMetadata.php b/core/lib/Drupal/Core/Render/BubbleableMetadata.php index 34905dd..32864e4 100644 --- a/core/lib/Drupal/Core/Render/BubbleableMetadata.php +++ b/core/lib/Drupal/Core/Render/BubbleableMetadata.php @@ -43,8 +43,8 @@ class BubbleableMetadata extends CacheableMetadata { public function merge(CacheableMetadata $other) { $result = parent::merge($other); if ($other instanceof BubbleableMetadata) { - $result->attached = empty($this->attached) ? $other->attached : \Drupal::service('renderer')->mergeAttachments($this->attached, $other->attached); - $result->postRenderCache = empty($this->postRenderCache) ? $other->postRenderCache : NestedArray::mergeDeep($this->postRenderCache, $other->postRenderCache); + $result->attached = empty($this->attached) ? $other->attached : (empty($other->attached) ? $this->attached : \Drupal::service('renderer')->mergeAttachments($this->attached, $other->attached)); + $result->postRenderCache = empty($this->postRenderCache) ? $other->postRenderCache : (empty($other->postRenderCache) ? $this->postRenderCache : NestedArray::mergeDeep($this->postRenderCache, $other->postRenderCache)); } return $result; }