From becfb36411c11baf06bfce9e28dc53e36bfbd362 Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Wed, 30 Oct 2024 12:02:14 +0100 Subject: [PATCH] IBX-8534: Added cache invalidation for source content when adding relation --- src/lib/Persistence/Cache/ContentHandler.php | 4 ++++ tests/lib/Persistence/Cache/ContentHandlerTest.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/Persistence/Cache/ContentHandler.php b/src/lib/Persistence/Cache/ContentHandler.php index a54e6bb293..68d8027f02 100644 --- a/src/lib/Persistence/Cache/ContentHandler.php +++ b/src/lib/Persistence/Cache/ContentHandler.php @@ -445,6 +445,10 @@ public function addRelation(RelationCreateStruct $relation) self::CONTENT_IDENTIFIER, [$relation->destinationContentId] ), + $this->cacheIdentifierGenerator->generateTag( + self::CONTENT_IDENTIFIER, + [$relation->sourceContentId] + ), ]); return $this->persistenceHandler->contentHandler()->addRelation($relation); diff --git a/tests/lib/Persistence/Cache/ContentHandlerTest.php b/tests/lib/Persistence/Cache/ContentHandlerTest.php index 38ccfcae05..7ce7d7bd6a 100644 --- a/tests/lib/Persistence/Cache/ContentHandlerTest.php +++ b/tests/lib/Persistence/Cache/ContentHandlerTest.php @@ -51,7 +51,7 @@ public function providerForUnCachedMethods(): array ['updateContent', [2, 1, new UpdateStruct()], [['content_version', [2, 1], false]], null, ['c-2-v-1']], //['deleteContent', [2]], own tests for relations complexity ['deleteVersion', [2, 1], [['content_version', [2, 1], false]], null, ['c-2-v-1']], - ['addRelation', [new RelationCreateStruct(['destinationContentId' => 2])], [['content', [2], false]], null, ['c-2']], + ['addRelation', [new RelationCreateStruct(['destinationContentId' => 2, 'sourceContentId' => 4])], [['content', [2], false], ['content', [4], false]], null, ['c-2', 'c-4']], ['removeRelation', [66, APIRelation::COMMON, 2], [['content', [2], false], ['relation', [66], false]], null, ['c-2', 're-66']], ['loadRelations', [2, 1, 3]], ['loadReverseRelations', [2, 3]],