From 843f61cfbf208a9d880b1aa4759478daad99755c Mon Sep 17 00:00:00 2001 From: DDEV User Date: Mon, 17 Jun 2024 16:48:28 +0000 Subject: [PATCH] Reset the context evaluation after setting the entity. --- src/Utility/DgiUtils.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Utility/DgiUtils.php b/src/Utility/DgiUtils.php index 7600a4e..bcb9ed9 100644 --- a/src/Utility/DgiUtils.php +++ b/src/Utility/DgiUtils.php @@ -66,6 +66,14 @@ public function executeEntityReactions(string $reaction_type, ContentEntityInter */ public function getActiveReactionsForEntity(string $reaction_type, ContentEntityInterface $entity) { $this->provider->setEntity($entity); + + // XXX: Need to force context re-evaluation to ensure that the entity being + // set by the provider in a single threaded scenario is evaluated once + // it has been changed. + $context_manager = new \ReflectionClass($this->contextManager); + $reset_context = $context_manager->getMethod('resetContextEvaluation'); + $reset_context->setAccessible(TRUE); + $reset_context->invoke($this->contextManager); $this->contextManager->evaluateContexts(); return $this->contextManager->getActiveReactions($reaction_type); }