use wcf\data\cronjob\Cronjob;
use wcf\system\background\BackgroundQueueHandler;
+use wcf\system\background\job\AbstractUniqueBackgroundJob;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\WCF;
WCF::getDB()->beginTransaction();
/** @noinspection PhpUnusedLocalVariableInspection */
$committed = false;
+ /** @var AbstractUniqueBackgroundJob[] $uniqueJobs */
+ $uniqueJobs = [];
try {
$sql = "SELECT jobID, job
FROM wcf" . WCF_N . "_background_job
BackgroundQueueHandler::getInstance()->enqueueIn($job, $job->retryAfter());
} else {
$job->onFinalFailure();
+
+ if ($job instanceof AbstractUniqueBackgroundJob) {
+ $uniqueJobs[] = $job;
+ }
}
}
} catch (\Exception $e) {
WCF::getDB()->rollBackTransaction();
}
}
+
+ // Requeue unique jobs if needed
+ foreach ($uniqueJobs as $job) {
+ if ($job->queueAgain()) {
+ BackgroundQueueHandler::getInstance()->enqueueIn($job->newInstance(), $job->retryAfter());
+ }
+ }
}
}