From 25b6571b63ea271a102c923c2b8cee5c0f1838be Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Tue, 7 Jan 2025 13:58:44 +0000 Subject: [PATCH] Issue #3495165 by catch, joeyroth, berdir, texas-bronius: Better warning message when variation cache detects an incompatible CacheRedirect --- core/lib/Drupal/Core/Cache/VariationCache.php | 3 ++- core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/VariationCache.php b/core/lib/Drupal/Core/Cache/VariationCache.php index c8b81ad7ee1c..8b49221ded29 100644 --- a/core/lib/Drupal/Core/Cache/VariationCache.php +++ b/core/lib/Drupal/Core/Cache/VariationCache.php @@ -136,7 +136,8 @@ public function set(array $keys, $data, CacheableDependencyInterface $cacheabili // lead to a value being returned. if (!array_diff($common_contexts, $previous_step_contexts)) { trigger_error(sprintf( - 'Trying to overwrite a cache redirect with one that has nothing in common, old one at address "%s" was pointing to "%s", new one points to "%s".', + 'Trying to overwrite a cache redirect for "%s" with one that has nothing in common, old one at address "%s" was pointing to "%s", new one points to "%s".', + $chain_cid, implode(', ', $previous_step_contexts), implode(', ', array_diff($result_contexts, $previous_step_contexts)), implode(', ', array_diff($contexts, $previous_step_contexts)), diff --git a/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php b/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php index de218a1a92e1..f207e34a7807 100644 --- a/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php @@ -441,7 +441,7 @@ public function testIncompleteRedirectException(): void { // a cache redirect should always be present on the redirect itself. In this // example, the final cache redirect should be for 'A,B:foo,B'. $this->expectException(\LogicException::class); - $this->expectExceptionMessage('Trying to overwrite a cache redirect with one that has nothing in common, old one at address "house.type" was pointing to "garden.type:zen", new one points to "garden.type".'); + $this->expectExceptionMessage('Trying to overwrite a cache redirect for "your:housing:situation:ht.house" with one that has nothing in common, old one at address "house.type" was pointing to "garden.type:zen", new one points to "garden.type".'); $this->housingType = 'house'; $house_cacheability = (new CacheableMetadata()) @@ -484,7 +484,7 @@ public function testIncompatibleRedirectsException(): void { // previous redirects should always be present on the next redirect or item // you're trying to store. $this->expectException(\LogicException::class); - $this->expectExceptionMessage('Trying to overwrite a cache redirect with one that has nothing in common, old one at address "house.type" was pointing to "garden.type", new one points to "house.orientation".'); + $this->expectExceptionMessage('Trying to overwrite a cache redirect for "your:housing:situation:ht.house" with one that has nothing in common, old one at address "house.type" was pointing to "garden.type", new one points to "house.orientation".'); $this->housingType = 'house'; $house_cacheability = (new CacheableMetadata()) @@ -523,7 +523,7 @@ public function testIncompatibleChainedRedirectsException(): void { }, E_USER_WARNING); $this->expectException(\LogicException::class); - $this->expectExceptionMessage('Trying to overwrite a cache redirect with one that has nothing in common, old one at address "house.type, garden.type" was pointing to "house.orientation", new one points to "solar.type".'); + $this->expectExceptionMessage('Trying to overwrite a cache redirect for "your:housing:situation:gt.garden:ht.house" with one that has nothing in common, old one at address "house.type, garden.type" was pointing to "house.orientation", new one points to "solar.type".'); $this->housingType = 'house'; $house_cacheability = (new CacheableMetadata()) @@ -572,7 +572,7 @@ public function testIncompatibleChainedRedirectsComplexException(): void { }, E_USER_WARNING); $this->expectException(\LogicException::class); - $this->expectExceptionMessage('Trying to overwrite a cache redirect with one that has nothing in common, old one at address "house.type, garden.type" was pointing to "house.orientation", new one points to "solar.type".'); + $this->expectExceptionMessage('Trying to overwrite a cache redirect for "your:housing:situation:gt.garden:ht.house" with one that has nothing in common, old one at address "house.type, garden.type" was pointing to "house.orientation", new one points to "solar.type".'); $this->housingType = 'house'; $house_cacheability = (new CacheableMetadata()) -- GitLab