diff --git a/src/Engine/MaestroEngine.php b/src/Engine/MaestroEngine.php index 7038fe37d5100304147fbc9069aa0c015294c1f4..d4178b80777bde6f2536e91b8b3d3677936c1ef3 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.