Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ProcessMaker/RollbackProcessRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public function rollback(
break;
}

// update the process request status to active
$processRequest = $this->newTask->processRequest;
$processRequest->status = 'ACTIVE';
$process = $processRequest->process;
Expand All @@ -135,9 +136,12 @@ public function rollback(
)->id;
$processRequest->saveOrFail();

// update the current task status to closed
$currentTask->status = 'CLOSED';
$currentTask->saveOrFail();

$this->syncParentProcessStatus($processRequest);

return $this->newTask;
}

Expand Down Expand Up @@ -209,4 +213,25 @@ private function addComment() : void
'case_number' => isset($this->currentTask->case_number) ? $this->currentTask->case_number : null,
]);
}

/**
* When the rolled-back request is a subprocess, reactivate the parent request
* and the parent's call activity tokens that were in error.
*/
private function syncParentProcessStatus(ProcessRequest $processRequest): void
{
$parentRequest = $processRequest->parentRequest;
if (!$parentRequest) {
return;
}

if (in_array($parentRequest->status, ['ERROR', 'FAILING'])) {
$parentRequest->status = 'ACTIVE';
$parentRequest->saveOrFail();
}

ProcessRequestToken::where('subprocess_request_id', $processRequest->id)
->whereIn('status', ['ERROR', 'FAILING'])
->update(['status' => 'ACTIVE']);
}
}
Loading