From a05f84ebade2e427977a746c73439f8c25da7928 Mon Sep 17 00:00:00 2001 From: Tran Lam Date: Wed, 7 May 2025 17:05:25 +0100 Subject: [PATCH 1/2] [133] Removed untouchable code --- .../src/WorkflowNotification.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/localgov_workflows_notifications/src/WorkflowNotification.php b/modules/localgov_workflows_notifications/src/WorkflowNotification.php index 4f4f626..3436971 100644 --- a/modules/localgov_workflows_notifications/src/WorkflowNotification.php +++ b/modules/localgov_workflows_notifications/src/WorkflowNotification.php @@ -59,9 +59,6 @@ public function enqueue(ContentEntityInterface $entity, string $type): void { break; } } - if ($queue_item !== FALSE && !$found) { - $queue->releaseItem($queue_item); - } if (!$found) { From f225451da2a7eeaa50dbcdef3128d9ef8049c4df Mon Sep 17 00:00:00 2001 From: Tran Lam Date: Wed, 7 May 2025 17:06:33 +0100 Subject: [PATCH 2/2] [133] Released queue_item for the next contact loop. --- .../src/WorkflowNotification.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/localgov_workflows_notifications/src/WorkflowNotification.php b/modules/localgov_workflows_notifications/src/WorkflowNotification.php index 3436971..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,6 +59,15 @@ public function enqueue(ContentEntityInterface $entity, string $type): void { $found = TRUE; break; } + else { + $claimed_items[] = $queue_item; + } + } + + if ($claimed_items) { + foreach ($claimed_items as $queue_item) { + $queue->releaseItem($queue_item); + } } if (!$found) {