diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2016-01-28 15:34:50 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-01-28 15:40:23 +0100 |
commit | 5238fc3f549d4eaddeb18a65493a3d27472c5f70 (patch) | |
tree | 10392e781884f34d1a853600daa5bfde0af2816b /cron.php | |
parent | 476720ada9f0997bdef7407f8ef15c2c50866011 (diff) | |
download | nextcloud-server-5238fc3f549d4eaddeb18a65493a3d27472c5f70.tar.gz nextcloud-server-5238fc3f549d4eaddeb18a65493a3d27472c5f70.zip |
Do not create a loop that generates thousands of jobs
Diffstat (limited to 'cron.php')
-rw-r--r-- | cron.php | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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 |