Skip to content

Commit a568aba

Browse files
Change array_rand
1 parent a41e840 commit a568aba

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

ProcessMaker/Models/FormalExpression.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,17 @@ function ($__data, $user_id, $assigned_groups) {
245245
return null;
246246
}
247247

248-
return $managers[array_rand($managers)];
248+
// Sort managers to ensure consistent round robin distribution
249+
sort($managers);
250+
251+
// Use a combination of process ID and request ID for better distribution
252+
// This ensures different processes don't interfere with each other's round robin
253+
$processId = $process->id ?? 0;
254+
$requestId = $__data['_request']['id'] ?? 0;
255+
$seed = $processId + $requestId;
256+
$managerIndex = $seed % count($managers);
257+
258+
return $managers[$managerIndex];
249259
}
250260

251261
return $user->manager_id;

0 commit comments

Comments
 (0)