From dead1b57202129f2ba694d9b147e6858eede0b17 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 27 Aug 2020 11:41:19 +0200 Subject: [PATCH 1/4] EZP-31768: Fixed cache invalidation during url alias relink --- eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php b/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php index 1595850fd99..bad845776f4 100644 --- a/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php +++ b/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php @@ -79,7 +79,12 @@ public function createCustomUrlAlias($locationId, $path, $forwarding = false, $l $alwaysAvailable ); - $this->cache->invalidateTags(['urlAlias-location-' . $locationId, 'urlAlias-location-path-' . $locationId, 'urlAlias-notFound']); + $this->cache->invalidateTags([ + 'urlAlias-location-' . $locationId, + 'urlAlias-location-path-' . $locationId, + 'urlAlias-notFound', + 'urlAlias-' . $urlAlias->id, + ]); return $urlAlias; } From c63c7fa950073b4eeff960d98676faa33f0c362d Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 27 Aug 2020 14:39:22 +0200 Subject: [PATCH 2/4] EZP-31768: Add additional condition for tag invalidation --- eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php b/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php index bad845776f4..45000810b12 100644 --- a/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php +++ b/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php @@ -83,9 +83,12 @@ public function createCustomUrlAlias($locationId, $path, $forwarding = false, $l 'urlAlias-location-' . $locationId, 'urlAlias-location-path-' . $locationId, 'urlAlias-notFound', - 'urlAlias-' . $urlAlias->id, ]); + if ($urlAlias instanceof UrlAlias) { + $this->cache->invalidateTags(['urlAlias-' . $urlAlias->id]); + } + return $urlAlias; } From dd8975e3e8af75987d3c0552f5ef1b5dd21a2b1b Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 27 Aug 2020 15:18:30 +0200 Subject: [PATCH 3/4] EZP-31768: Adapted related test --- .../Core/Persistence/Cache/Tests/UrlAliasHandlerTest.php | 2 +- eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/eZ/Publish/Core/Persistence/Cache/Tests/UrlAliasHandlerTest.php b/eZ/Publish/Core/Persistence/Cache/Tests/UrlAliasHandlerTest.php index 4d0648c7989..20946998f15 100644 --- a/eZ/Publish/Core/Persistence/Cache/Tests/UrlAliasHandlerTest.php +++ b/eZ/Publish/Core/Persistence/Cache/Tests/UrlAliasHandlerTest.php @@ -29,7 +29,7 @@ public function providerForUnCachedMethods(): array // string $method, array $arguments, array? $tags, array? $key, mixed? $returnValue return [ ['publishUrlAliasForLocation', [44, 2, 'name', 'eng-GB', true, false], ['urlAlias-location-44', 'urlAlias-location-path-44', 'urlAlias-notFound']], - ['createCustomUrlAlias', [44, '1/2/44', true, null, false], ['urlAlias-location-44', 'urlAlias-location-path-44', 'urlAlias-notFound']], + ['createCustomUrlAlias', [44, '1/2/44', true, null, false], ['urlAlias-location-44', 'urlAlias-location-path-44', 'urlAlias-notFound', 'urlAlias-5'], null, new UrlAlias(['id' => 5])], ['createGlobalUrlAlias', ['something', '1/2/44', true, null, false], ['urlAlias-notFound']], ['createGlobalUrlAlias', ['something', '1/2/44', true, 'eng-GB', false], ['urlAlias-notFound']], ['listGlobalURLAliases', ['eng-GB', 10, 50]], diff --git a/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php b/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php index 45000810b12..f262a82957e 100644 --- a/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php +++ b/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php @@ -83,12 +83,9 @@ public function createCustomUrlAlias($locationId, $path, $forwarding = false, $l 'urlAlias-location-' . $locationId, 'urlAlias-location-path-' . $locationId, 'urlAlias-notFound', + 'urlAlias-' . $urlAlias->id ]); - if ($urlAlias instanceof UrlAlias) { - $this->cache->invalidateTags(['urlAlias-' . $urlAlias->id]); - } - return $urlAlias; } From b2a7f0ca23f6a40455272529d48e1d5ab8f992b4 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 27 Aug 2020 15:46:19 +0200 Subject: [PATCH 4/4] EZP-31768: CS --- eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php b/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php index f262a82957e..bad845776f4 100644 --- a/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php +++ b/eZ/Publish/Core/Persistence/Cache/UrlAliasHandler.php @@ -83,7 +83,7 @@ public function createCustomUrlAlias($locationId, $path, $forwarding = false, $l 'urlAlias-location-' . $locationId, 'urlAlias-location-path-' . $locationId, 'urlAlias-notFound', - 'urlAlias-' . $urlAlias->id + 'urlAlias-' . $urlAlias->id, ]); return $urlAlias;