From 4379beb74c8f0f4efdf2d65705f295ee480e41a8 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Fri, 28 Oct 2022 10:03:41 -0700 Subject: [PATCH] Created config option to disable auto cron --- src/bb-config-sample.php | 5 +++++ src/bb-library/Box/Tools.php | 1 + src/bb-modules/System/Service.php | 3 ++- src/install/install.php | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bb-config-sample.php b/src/bb-config-sample.php index b474e995e..578c087c9 100755 --- a/src/bb-config-sample.php +++ b/src/bb-config-sample.php @@ -56,6 +56,11 @@ return [ 'allowed_ips' => [], ], + /** + * FOSSBilling will automatically execute cron when you login to the admin panel if it hasn't been executed in awhile. You can disable this fallback here. + */ + 'disable_auto_cron' => false, + /** * Enable or disable search engine friendly URLs. * Configure .htaccess file before enabling this feature diff --git a/src/bb-library/Box/Tools.php b/src/bb-library/Box/Tools.php index 9a778056e..1942e2178 100644 --- a/src/bb-library/Box/Tools.php +++ b/src/bb-library/Box/Tools.php @@ -498,6 +498,7 @@ class Box_Tools 'salt' => $currentConfig['salt'], 'url' => $currentConfig['url'], 'admin_area_prefix' => $currentConfig['admin_area_prefix'], + 'disable_auto_cron' => (isset($currentConfig['disable_auto_cron'])) ? $currentConfig['disable_auto_cron'] : false, 'sef_urls' => $currentConfig['sef_urls'], 'timezone' => $currentConfig['timezone'], 'locale' => $currentConfig['locale'], diff --git a/src/bb-modules/System/Service.php b/src/bb-modules/System/Service.php index 528532834..ddaaa48e3 100644 --- a/src/bb-modules/System/Service.php +++ b/src/bb-modules/System/Service.php @@ -243,7 +243,8 @@ class Service error_log($e->getMessage()); } $last_exec = $this->getParamValue('last_cron_exec'); - if($runFromTest === false) { + $disableAutoCron = isset($this->di['config']['disable_auto_cron']) ? $this->di['config']['disable_auto_cron'] : false; + if($runFromTest === false && $disableAutoCron === false) { if (!$last_exec) { $msgs['info'][] = 'Cron was never executed. FOSSBilling will automatically execute cron when you access the admin panel, but you should make sure you have setup cron the job.'; $cronService = $this->di['mod_service']('cron'); diff --git a/src/install/install.php b/src/install/install.php index f0b662dea..05f969036 100644 --- a/src/install/install.php +++ b/src/install/install.php @@ -421,6 +421,7 @@ final class Box_Installer 'salt' => md5(random_bytes(13)), 'url' => BB_URL, 'admin_area_prefix' => '/admin', + 'disable_auto_cron' => false, 'sef_urls' => true, 'timezone' => 'UTC', 'locale' => 'en_US',