Skip to content

Commit

Permalink
Only cache terms that exist (Islandora#2272)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ant Brown committed Apr 10, 2024
1 parent bd377ee commit 14a6715
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/IslandoraUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,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;
}

Expand Down

0 comments on commit 14a6715

Please sign in to comment.