Skip to content

Commit

Permalink
Fix the cron step UID definition
Browse files Browse the repository at this point in the history
  • Loading branch information
andergmartins committed Dec 9, 2024
1 parent 1e0c16f commit 7651e0d
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public function setup(array $step, callable $actionCallback): void

$isSingleAction = self::SCHEDULE_RECURRENCE_SINGLE === $recurrence;

$actionUIDHash = $this->getScheduledActionUniqueIdHash($node);
$actionUID = $this->getScheduledActionUniqueId($node);
$actionUIDHash = md5($actionUID);
$scheduledActionId = 0;

$workflowId = $this->variablesHandler->getVariable('global.workflow.id');
Expand Down Expand Up @@ -307,7 +308,7 @@ public function setup(array $step, callable $actionCallback): void
$scheduledStepModel->setActionId($scheduledActionId);
$scheduledStepModel->setWorkflowId($workflowId);
$scheduledStepModel->setStepId($node['id']);
$scheduledStepModel->setActionUID($actionUIDHash);
$scheduledStepModel->setActionUID($actionUID);
$scheduledStepModel->setArgs($compactedArgs);
$scheduledStepModel->setRunCount(0);
$scheduledStepModel->setIsRecurring(! $isSingleAction);
Expand Down Expand Up @@ -390,23 +391,24 @@ private function getSchedulingTimestamp(array $nodeSettings)
return $timestamp;
}

private function getScheduledActionUniqueIdHash(array $node): string
private function getScheduledActionUniqueId(array $node): string
{
$uniqueId = [
'workflowId' => $this->variablesHandler->getVariable('global.workflow.id'),
'stepId' => $node['id'],
'custom' => '',
'stepId' => $node['id']
];

if (isset($node['data']['settings']['schedule']['uniqueIdExpression'])) {
$uniqueIdExpression = $node['data']['settings']['schedule']['uniqueIdExpression'];

if (! empty($uniqueIdExpression)) {
$uniqueId['custom'] = $this->variablesHandler->replacePlaceholdersInText($uniqueIdExpression);
$uniqueId = [
'custom' => $this->variablesHandler->replacePlaceholdersInText($uniqueIdExpression),
];
}
}

return md5(wp_json_encode($uniqueId));
return wp_json_encode($uniqueId);
}

public function compactArguments(array $step): array
Expand Down

0 comments on commit 7651e0d

Please sign in to comment.