Skip to content
Snippets Groups Projects
Commit 5238fc3f authored by Joas Schilling's avatar Joas Schilling
Browse files

Do not create a loop that generates thousands of jobs

parent 476720ad
No related branches found
No related tags found
No related merge requests found
......@@ -130,11 +130,20 @@ try {
// Work
$jobList = \OC::$server->getJobList();
$jobs = $jobList->getAll();
foreach ($jobs as $job) {
$executedJobs = [];
while ($job = $jobList->getNext()) {
if (isset($executedJobs[$job->getId()])) {
break;
}
$logger->debug('Run job with ID ' . $job->getId(), ['app' => 'cron']);
$job->execute($jobList, $logger);
$logger->debug('Finished job with ID ' . $job->getId(), ['app' => 'cron']);
$jobList->setLastJob($job);
$executedJobs[$job->getId()] = true;
unset($job);
}
// unlock the file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment