Delete tasks without queues when fetching sending tasks

[MAILPOET-3379]
This commit is contained in:
wxa
2021-03-03 11:54:11 +03:00
committed by Veljko V
parent bf121c20b5
commit 3f7b809bd4
2 changed files with 19 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
namespace MailPoet\Tasks;
use MailPoet\Logging\LoggerFactory;
use MailPoet\Models\ScheduledTask;
use MailPoet\Models\ScheduledTaskSubscriber;
use MailPoet\Models\SendingQueue;
@@ -97,11 +98,22 @@ class Sending {
foreach ($tasks as $task) {
if (!empty($queuesIndex[$task->id])) {
$result[] = self::create($task, $queuesIndex[$task->id]);
} else {
static::handleInvalidTask($task);
}
}
return $result;
}
public static function handleInvalidTask(ScheduledTask $task) {
$loggerFactory = LoggerFactory::getInstance();
$loggerFactory->getLogger(LoggerFactory::TOPIC_NEWSLETTERS)->addError(
'invalid sending task found, deleting',
['task_id' => $task->id]
);
$task->delete();
}
public static function createFromScheduledTask(ScheduledTask $task) {
$queue = SendingQueue::where('task_id', $task->id)->findOne();
if (!$queue) {