From 044acd7ffd4a03a72bb9906933b4d63dd1437971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Karlovi=C4=87?= Date: Wed, 6 Nov 2024 12:30:54 +0100 Subject: [PATCH] fix: clear permission cache on configuration save --- src/WorkspaceHelper.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/WorkspaceHelper.php b/src/WorkspaceHelper.php index 2f874119..6edbf5cb 100644 --- a/src/WorkspaceHelper.php +++ b/src/WorkspaceHelper.php @@ -170,6 +170,7 @@ public static function saveWorkspaces(Configuration $config, $workspaces) } } } + Cache::clearTags(self::getCacheTags($config)); } /** @@ -210,6 +211,8 @@ public static function deleteConfiguration(Configuration $config) $db->delete(Dao::TABLE_NAME_DOCUMENT, ['configuration' => $config->getName()]); $db->delete(Dao::TABLE_NAME_ASSET, ['configuration' => $config->getName()]); $db->delete(Dao::TABLE_NAME_DATAOBJECT, ['configuration' => $config->getName()]); + + Cache::clearTags(self::getCacheTags($config)); } /** @@ -302,7 +305,7 @@ public static function isAllowed($element, Configuration $configuration, string private static function fetchLookupTable(string $elementType, Configuration $configuration): array { - $cacheKey = 'datahub_permissions_' . $configuration->getName() . '_' . $elementType; + $cacheKey = 'datahub_workspace_permissions_' . $configuration->getName() . '_' . $elementType; if (RuntimeCache::isRegistered($cacheKey)) { return RuntimeCache::load($cacheKey); } @@ -324,8 +327,13 @@ private static function fetchLookupTable(string $elementType, Configuration $con } RuntimeCache::save($lookupTable, $cacheKey); - Cache::save($lookupTable, $cacheKey); + Cache::save($lookupTable, $cacheKey, self::getCacheTags($configuration)); return $lookupTable; } + + private static function getCacheTags(Configuration $configuration): array + { + return ['datahub_workspace_permissions_'. $configuration->getName()]; + } }