diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-08-26 20:22:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 20:22:37 +0200 |
commit | c9a1379bdf99013c7f0bf9510f0e9f7955100ff7 (patch) | |
tree | 20b2dca6e0cc5c63edd9f1ccf02adba31e10592b | |
parent | 7aeb2224261e21160bdbf0bbb1b7f6ec0e3c7b6a (diff) | |
parent | f8417cca0f1ac429041784af5417062a781f7d3e (diff) | |
download | nextcloud-server-c9a1379bdf99013c7f0bf9510f0e9f7955100ff7.tar.gz nextcloud-server-c9a1379bdf99013c7f0bf9510f0e9f7955100ff7.zip |
Merge pull request #22410 from nextcloud/backport/22359/stable19
[stable19] fix possible leaking scope in Flow
-rw-r--r-- | apps/workflowengine/lib/AppInfo/Application.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Service/RuleMatcher.php | 14 | ||||
-rw-r--r-- | lib/public/WorkflowEngine/IRuleMatcher.php | 10 |
3 files changed, 25 insertions, 0 deletions
diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php index 70b5468c553..57cfee7f1a0 100644 --- a/apps/workflowengine/lib/AppInfo/Application.php +++ b/apps/workflowengine/lib/AppInfo/Application.php @@ -95,6 +95,7 @@ class Application extends \OCP\AppFramework\App { /** @var IOperation $operation */ $operation = $this->getContainer()->query($operationClass); + $ruleMatcher->setEventName($eventName); $ruleMatcher->setEntity($entity); $ruleMatcher->setOperation($operation); diff --git a/apps/workflowengine/lib/Service/RuleMatcher.php b/apps/workflowengine/lib/Service/RuleMatcher.php index f02c28fa27e..6bad3cefd5d 100644 --- a/apps/workflowengine/lib/Service/RuleMatcher.php +++ b/apps/workflowengine/lib/Service/RuleMatcher.php @@ -62,6 +62,8 @@ class RuleMatcher implements IRuleMatcher { protected $entity; /** @var Logger */ protected $logger; + /** @var string */ + protected $eventName; public function __construct( IUserSession $session, @@ -101,6 +103,13 @@ class RuleMatcher implements IRuleMatcher { $this->entity = $entity; } + public function setEventName(string $eventName): void { + if ($this->eventName !== null) { + throw new RuntimeException('This method must not be called more than once'); + } + $this->eventName = $eventName; + } + public function getEntity(): IEntity { if ($this->entity === null) { throw new \LogicException('Entity was not set yet'); @@ -155,6 +164,11 @@ class RuleMatcher implements IRuleMatcher { $matches = []; foreach ($operations as $operation) { + $configuredEvents = json_decode($operation['events'], true); + if ($this->eventName !== null && !in_array($this->eventName, $configuredEvents)) { + continue; + } + $checkIds = json_decode($operation['checks'], true); $checks = $this->manager->getChecks($checkIds); diff --git a/lib/public/WorkflowEngine/IRuleMatcher.php b/lib/public/WorkflowEngine/IRuleMatcher.php index cb52001a1a2..d2bef889520 100644 --- a/lib/public/WorkflowEngine/IRuleMatcher.php +++ b/lib/public/WorkflowEngine/IRuleMatcher.php @@ -78,4 +78,14 @@ interface IRuleMatcher extends IFileCheck { * @since 18.0.0 */ public function getEntity(): IEntity; + + /** + * this method can be called once to set the event name that is currently + * being processed. The workflow engine takes care of this usually, only an + * IComplexOperation might want to make use of it. + * + * @throws RuntimeException + * @since 19.0.3 + */ + public function setEventName(string $eventName): void; } |