Skip to content

Commit 76f9561

Browse files
authored
Merge pull request #8594 from ProcessMaker/bugfix/FOUR-27709
FOUR-27709: ABE does not work correctly when a parallel gateway is part of the flow
2 parents ea921ad + 725ffe4 commit 76f9561

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

ProcessMaker/Jobs/CompleteActivity.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use ProcessMaker\Models\Process as Definitions;
99
use ProcessMaker\Models\ProcessRequestToken;
1010
use ProcessMaker\Nayra\Contracts\Bpmn\ActivityInterface;
11+
use ProcessMaker\Nayra\Contracts\Bpmn\CallActivityInterface;
1112
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
1213
use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;
1314

@@ -42,8 +43,10 @@ public function __construct(Definitions $definitions, ExecutionInstanceInterface
4243
public function action(ProcessRequestToken $token, ActivityInterface $element, array $data)
4344
{
4445
//@todo requires a class to manage the data access and control the updates
45-
$manager = new DataManager();
46-
$manager->updateData($token, $data);
46+
if (!($element instanceof CallActivityInterface)) {
47+
$manager = new DataManager();
48+
$manager->updateData($token, $data);
49+
}
4750
$this->engine->runToNextState();
4851
$element->complete($token);
4952

ProcessMaker/Jobs/ThrowMessageEvent.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,19 @@ public function action(ProcessRequest $instance, CatchEventInterface $element)
4848
$message->setId($this->messageRef);
4949
$eventDefinition->setPayload($message);
5050
$eventDefinition->setProperty('messageRef', $this->messageRef);
51+
$eventDefinition->setProperty('target_catch_event_id', $this->elementId);
52+
$eventDefinition->setProperty('target_instance_id', $this->instanceId);
5153

52-
$this->engine->getEventDefinitionBus()->dispatchEventDefinition(
53-
null,
54-
$eventDefinition,
55-
null
56-
);
5754
if ($this->payload) {
5855
foreach ($this->payload as $key => $value) {
5956
$instance->getDataStore()->putData($key, $value);
6057
}
6158
}
59+
60+
$this->engine->getEventDefinitionBus()->dispatchEventDefinition(
61+
null,
62+
$eventDefinition,
63+
null
64+
);
6265
}
6366
}

ProcessMaker/Models/CallActivity.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,26 @@ protected function callSubprocess(TokenInterface $token, $startId)
9494
*/
9595
protected function completeSubprocess(TokenInterface $token, ExecutionInstanceInterface $closedInstance, ExecutionInstanceInterface $instance)
9696
{
97-
// Copy data from subprocess to main process
98-
$data = $closedInstance->getDataStore()->getData();
97+
$store = $closedInstance->getDataStore();
98+
$allData = $store->getData();
99+
100+
// Determine which data should be merged back from the subprocess.
101+
$updatedKeys = method_exists($store, 'getUpdated')
102+
? $store->getUpdated()
103+
: null;
104+
105+
if ($updatedKeys === null) {
106+
// Legacy behavior or no tracking available: copy all data.
107+
$data = $allData;
108+
} elseif ($updatedKeys === []) {
109+
// Nothing was updated in the subprocess: do not merge anything.
110+
$data = [];
111+
} else {
112+
// Merge only the explicitly updated keys.
113+
$updatedKeys = array_values((array) $updatedKeys);
114+
$data = array_intersect_key($allData, array_flip($updatedKeys));
115+
}
116+
99117
$dataManager = new DataManager();
100118
$dataManager->updateData($token, $data);
101119
$token->getInstance()->getProcess()->getEngine()->runToNextState();

0 commit comments

Comments
 (0)