From dcbddf3944ad7ed6e0c41285ac0413788e777c16 Mon Sep 17 00:00:00 2001 From: Ant Brown Date: Wed, 10 Apr 2024 16:10:25 +1200 Subject: [PATCH] Only cache terms that exist (Islandora#2272) --- src/IslandoraUtils.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/IslandoraUtils.php b/src/IslandoraUtils.php index 06628c697..b39ce3da4 100644 --- a/src/IslandoraUtils.php +++ b/src/IslandoraUtils.php @@ -311,15 +311,14 @@ public function getTermForUri($uri) { if (!empty($results)) { $term = $this->entityTypeManager->getStorage('taxonomy_term') ->load(reset($results)); + $this->cache->set( + $cid, + $term, + CacheBackendInterface::CACHE_PERMANENT, + Cache::mergeTags(array_merge($term->getCacheTags(), ['user:' . $this->currentUser->id()])) + ); } - $this->cache->set( - $cid, - $term, - CacheBackendInterface::CACHE_PERMANENT, - Cache::mergeTags(array_merge($term->getCacheTags(), ['user:' . $this->currentUser->id()])) - ); - return $term; }