From 983a04c8bea16eeb4919e26a7ec6bb5a143c84f9 Mon Sep 17 00:00:00 2001 From: _randy <rkolenko@gmail.com> Date: Wed, 20 Sep 2023 13:52:28 -0400 Subject: [PATCH] Issue #3388643: Engine nextStep sporadically re-creates preceeding task from AND --- src/Engine/MaestroEngine.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Engine/MaestroEngine.php b/src/Engine/MaestroEngine.php index 7038fe3..d4178b8 100644 --- a/src/Engine/MaestroEngine.php +++ b/src/Engine/MaestroEngine.php @@ -1634,12 +1634,32 @@ class MaestroEngine { // We don't need to recreate if this thing is already in the queue. $query->condition('archived', '0') ->accessCheck(FALSE) - ->condition('status', TASK_STATUS_ACTIVE)->condition('process_id', $processID) + ->condition('status', TASK_STATUS_ACTIVE) + ->condition('process_id', $processID) ->condition('task_id', $taskID); $entity_ids = $query->execute(); // Means we haven't already created it in this process. avoids mimicking the regen issue. if (count($entity_ids) == 0) { - $queueID = $this->createProductionTask($taskID, $template, $processID); + // Detect if this is an AND task we're about to create. + // If so, see if it has already been completed in this process instance + // and is not a regen. + $nextTask = $this->getTemplateTaskByID($template, $taskID); + if($nextTask['tasktype'] == 'MaestroAnd') { + $query = \Drupal::entityTypeManager()->getStorage('maestro_queue')->getQuery(); + $query->condition('archived', TASK_ARCHIVE_REGEN, '<>') + ->accessCheck(FALSE) + ->condition('status', TASK_STATUS_SUCCESS) + ->condition('process_id', $processID) + ->condition('task_id', $taskID); + $entity_ids = $query->execute(); + if (count($entity_ids) == 0) { + $queueID = $this->createProductionTask($taskID, $template, $processID); + } + } + else { + $queueID = $this->createProductionTask($taskID, $template, $processID); + } + } } // REGENERATION. -- GitLab