Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
// We only ask for jobs for 14 minutes, because after 15 minutes the next
// system cron task should spawn.
$endTime = time() + 14 * 60;
$currentVersion = $config->getSystemValue('version', '');

$executedJobs = [];
while ($job = $jobList->getNext()) {
Expand All @@ -128,14 +129,18 @@
$executedJobs[$job->getId()] = true;
unset($job);

if (time() > $endTime) {
if (time() > $endTime ||
$config->getSystemValue('maintenance', false) ||
$currentVersion !== $config->getSystemValue('version', '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure, that this will not work, because the config is already loaded and will still hold the old version.

) {
// Time over or there is/was an update, make sure we don't continue with old cached data...
break;
}
}

} else {
// We call cron.php from some website
if ($appMode == 'cron') {
if ($appMode === 'cron') {
// Cron is cron :-P
OC_JSON::error(array('data' => array('message' => 'Backgroundjobs are using system cron!')));
} else {
Expand All @@ -151,7 +156,7 @@
}

// Log the successful cron execution
\OC::$server->getConfig()->setAppValue('core', 'lastcron', time());
$config->setAppValue('core', 'lastcron', time());
exit();

} catch (Exception $ex) {
Expand Down