summaryrefslogtreecommitdiffstats
path: root/cron.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2016-01-28 15:34:50 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2016-01-28 15:40:23 +0100
commit5238fc3f549d4eaddeb18a65493a3d27472c5f70 (patch)
tree10392e781884f34d1a853600daa5bfde0af2816b /cron.php
parent476720ada9f0997bdef7407f8ef15c2c50866011 (diff)
downloadnextcloud-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.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/cron.php b/cron.php
index afcf47cb0e9..73f233e1350 100644
--- a/cron.php
+++ b/cron.php
@@ -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