Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix(cron.php): Use new IAppConfig interface in cron.php
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Feb 8, 2024
commit 65d013b9aefc2e8c5ae3d1f4c02368f79201e209
8 changes: 5 additions & 3 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

use OC\SystemConfig;
use OCP\BackgroundJob\IJobList;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\ISession;
use OCP\ITempManager;
Expand Down Expand Up @@ -78,6 +79,7 @@

$logger = Server::get(LoggerInterface::class);
$config = Server::get(IConfig::class);
$appConfig = Server::get(IAppConfig::class);
$tempManager = Server::get(ITempManager::class);

// Don't do anything if Nextcloud has not been installed
Expand All @@ -88,7 +90,7 @@
$tempManager->cleanOld();

// Exit if background jobs are disabled!
$appMode = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax');
$appMode = $appConfig->getValueString('core', 'backgroundjobs_mode', 'ajax');
if ($appMode === 'none') {
if (OC::$CLI) {
echo 'Background Jobs are disabled!' . PHP_EOL;
Expand Down Expand Up @@ -122,7 +124,7 @@

// We call Nextcloud from the CLI (aka cron)
if ($appMode !== 'cron') {
$config->setAppValue('core', 'backgroundjobs_mode', 'cron');
$appConfig->setValueString('core', 'backgroundjobs_mode', 'cron');
}

// Low-load hours
Expand Down Expand Up @@ -211,7 +213,7 @@
}

// Log the successful cron execution
$config->setAppValue('core', 'lastcron', time());
$appConfig->setValueInt('core', 'lastcron', time());
exit();
} catch (Exception $ex) {
Server::get(LoggerInterface::class)->error(
Expand Down