diff --git a/modules/localgov_workflows_notifications/src/WorkflowNotification.php b/modules/localgov_workflows_notifications/src/WorkflowNotification.php index 4f4f626..45ec023 100644 --- a/modules/localgov_workflows_notifications/src/WorkflowNotification.php +++ b/modules/localgov_workflows_notifications/src/WorkflowNotification.php @@ -44,6 +44,7 @@ public function enqueue(ContentEntityInterface $entity, string $type): void { // Ensure the queue contains only one item for per service contact. $found = FALSE; + $claimed_items = []; while ($queue_item = $queue->claimItem(1)) { if ($queue_item->data->service_contact == $contact->id()) { @@ -58,9 +59,15 @@ public function enqueue(ContentEntityInterface $entity, string $type): void { $found = TRUE; break; } + else { + $claimed_items[] = $queue_item; + } } - if ($queue_item !== FALSE && !$found) { - $queue->releaseItem($queue_item); + + if ($claimed_items) { + foreach ($claimed_items as $queue_item) { + $queue->releaseItem($queue_item); + } } if (!$found) {