Skip to content

Commit be4511d

Browse files
committed
fix(CursorComment): improve data merging logic in completeSubprocess method
1 parent 7a45299 commit be4511d

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

ProcessMaker/Models/CallActivity.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,26 @@ protected function callSubprocess(TokenInterface $token, $startId)
9494
*/
9595
protected function completeSubprocess(TokenInterface $token, ExecutionInstanceInterface $closedInstance, ExecutionInstanceInterface $instance)
9696
{
97-
// Copy only the data updated by the subprocess
9897
$store = $closedInstance->getDataStore();
99-
$data = $store->getData();
100-
$updatedKeys = method_exists($store, 'getUpdated') ? $store->getUpdated() : array_keys($data);
101-
if (!empty($updatedKeys)) {
102-
$data = array_intersect_key($data, array_flip($updatedKeys));
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));
103115
}
116+
104117
$dataManager = new DataManager();
105118
$dataManager->updateData($token, $data);
106119
$token->getInstance()->getProcess()->getEngine()->runToNextState();

0 commit comments

Comments
 (0)