From cd4aad1ab6a99f9aaed1306e3b051a946944a648 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 15 Feb 2023 15:36:32 +0100 Subject: Also check the scope when reading operations from the database Signed-off-by: Joas Schilling --- apps/workflowengine/lib/Manager.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'apps/workflowengine/lib/Manager.php') diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index 8aeb588d016..a06b56dc208 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -189,6 +189,13 @@ class Manager implements IManager { return $scopesByOperation[$operationClass]; } + try { + /** @var IOperation $operation */ + $operation = $this->container->query($operationClass); + } catch (QueryException $e) { + return []; + } + $query = $this->connection->getQueryBuilder(); $query->selectDistinct('s.type') @@ -203,6 +210,11 @@ class Manager implements IManager { $scopesByOperation[$operationClass] = []; while ($row = $result->fetch()) { $scope = new ScopeContext($row['type'], $row['value']); + + if (!$operation->isAvailableForScope((int) $row['type'])) { + continue; + } + $scopesByOperation[$operationClass][$scope->getHash()] = $scope; } @@ -232,6 +244,17 @@ class Manager implements IManager { $this->operations[$scopeContext->getHash()] = []; while ($row = $result->fetch()) { + try { + /** @var IOperation $operation */ + $operation = $this->container->query($row['class']); + } catch (QueryException $e) { + continue; + } + + if (!$operation->isAvailableForScope((int) $row['scope_type'])) { + continue; + } + if (!isset($this->operations[$scopeContext->getHash()][$row['class']])) { $this->operations[$scopeContext->getHash()][$row['class']] = []; } -- cgit v1.2.3