Update database entry only when an actual change happend
[MAILPOET-4430]
This commit is contained in:
@ -39,19 +39,20 @@ class UpdateWorkflowController {
|
||||
}
|
||||
|
||||
$changed = false;
|
||||
$storedData = $workflow->toArray();
|
||||
|
||||
if (array_key_exists('name', $data)) {
|
||||
if (array_key_exists('name', $data) && $workflow->getName() !== $data['name']) {
|
||||
$workflow->setName($data['name']);
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
if (array_key_exists('status', $data)) {
|
||||
if (array_key_exists('status', $data) && $workflow->getStatus() !== $data['status']) {
|
||||
$this->checkWorkflowStatus($data['status']);
|
||||
$workflow->setStatus($data['status']);
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
if (array_key_exists('steps', $data)) {
|
||||
if (array_key_exists('steps', $data) && json_decode($storedData['steps'], true) !== $data['steps']) {
|
||||
$this->validateWorkflowSteps($workflow, $data['steps']);
|
||||
$this->updateStepsController->updateSteps($workflow, $data['steps']);
|
||||
foreach ($workflow->getSteps() as $step) {
|
||||
@ -61,11 +62,13 @@ class UpdateWorkflowController {
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
if ($changed) {
|
||||
$this->hooks->doWorkflowBeforeSave($workflow);
|
||||
$this->storage->updateWorkflow($workflow);
|
||||
if (!$changed) {
|
||||
return $workflow;
|
||||
}
|
||||
|
||||
$this->hooks->doWorkflowBeforeSave($workflow);
|
||||
$this->storage->updateWorkflow($workflow);
|
||||
|
||||
$workflow = $this->storage->getWorkflow($id);
|
||||
if (!$workflow) {
|
||||
throw Exceptions::workflowNotFound($id);
|
||||
|
Reference in New Issue
Block a user