From 14fb7a20046765b7c5c7f9d045b90cab0a040513 Mon Sep 17 00:00:00 2001 From: Prashant Kanse Date: Mon, 29 Jul 2024 15:22:21 -0400 Subject: [PATCH] DDST-382: Handle errors while deleting orphaned embargo --- src/Entity/Embargo.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Entity/Embargo.php b/src/Entity/Embargo.php index 89349b8..81a0f57 100644 --- a/src/Entity/Embargo.php +++ b/src/Entity/Embargo.php @@ -397,29 +397,33 @@ public function getCacheMaxAge() { * {@inheritdoc} */ public function getCacheTags() { - $tags = Cache::mergeTags(parent::getCacheTags(), $this->getEmbargoedNode()->getCacheTags()); + if ($this->getEmbargoedNode() !== NULL) { + $tags = Cache::mergeTags(parent::getCacheTags(), $this->getEmbargoedNode()->getCacheTags()); - if ($this->getExemptIps()) { - $tags = Cache::mergeTags($tags, $this->getExemptIps()->getCacheTags()); + if ($this->getExemptIps()) { + $tags = Cache::mergeTags($tags, $this->getExemptIps()->getCacheTags()); + } + return $tags; } - return $tags; } /** * {@inheritDoc} */ public function getCacheContexts() { - $contexts = Cache::mergeContexts( - parent::getCacheContexts(), - $this->getEmbargoedNode()->getCacheContexts(), - ['user.embargo__has_exemption'], - ); - - if ($this->getExemptIps()) { - $contexts = Cache::mergeContexts($contexts, $this->getExemptIps()->getCacheContexts()); + if ($this->getEmbargoedNode() !== NULL) { + $contexts = Cache::mergeContexts( + parent::getCacheContexts(), + $this->getEmbargoedNode()->getCacheContexts(), + ['user.embargo__has_exemption'], + ); + + if ($this->getExemptIps()) { + $contexts = Cache::mergeContexts($contexts, $this->getExemptIps()->getCacheContexts()); + } + + return $contexts; } - - return $contexts; } /**