From 74755f8074e1658ece9ee45dde2e34502e348929 Mon Sep 17 00:00:00 2001 From: Lucas van Schaik Date: Fri, 17 Feb 2023 16:56:42 +0100 Subject: [PATCH] Implement solution for drupal issues 3089660 and 3045666 --- src/IslandoraContextManager.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/IslandoraContextManager.php b/src/IslandoraContextManager.php index 801e3253..9a318a5b 100644 --- a/src/IslandoraContextManager.php +++ b/src/IslandoraContextManager.php @@ -48,7 +48,11 @@ class IslandoraContextManager extends ContextManager { $conditions = $context->getConditions(); // Apply context to any context aware conditions. - $this->applyContexts($conditions, $provided); + // Abort if the application of contexts has been unsuccessful + // similarly to BlockAccessControlHandler::checkAccess(). + if (!$this->applyContexts($conditions, $provided)) { + return FALSE; + } // Set the logic to use when validating the conditions. $logic = $context->requiresAllConditions() @@ -76,6 +80,7 @@ class IslandoraContextManager extends ContextManager { * TRUE if conditions pass */ protected function applyContexts(ConditionPluginCollection &$conditions, array $provided = []) { + $passed = FALSE; foreach ($conditions as $condition) { if ($condition instanceof ContextAwarePluginInterface) { try { @@ -86,14 +91,15 @@ class IslandoraContextManager extends ContextManager { $contexts = $provided; } $this->contextHandler->applyContextMapping($condition, $contexts); + $passed = TRUE; } catch (ContextException $e) { - return FALSE; + continue; } } } - return TRUE; + return $passed; } }