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 Jul 30, 2024
1 parent 579e056 commit dcbddf3
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 @@ -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;
}

Expand Down

0 comments on commit dcbddf3

Please sign in to comment.