diff --git a/application/config/config.sample.php b/application/config/config.sample.php index 335522087..3bd0250d9 100644 --- a/application/config/config.sample.php +++ b/application/config/config.sample.php @@ -695,4 +695,16 @@ $config['disable_impersonate'] = false; | */ -$config['cron_allow_insecure'] = false; \ No newline at end of file +$config['cron_allow_insecure'] = false; + +/* +|-------------------------------------------------------------------------- +| Update / version check +|-------------------------------------------------------------------------- + +| This config switch disables the check for newer releases on github and +| hides the banner to admin users if a newer release as published. +| Default ON. + */ + +$config['disable_version_check'] = false; \ No newline at end of file diff --git a/application/controllers/Debug.php b/application/controllers/Debug.php index b0c68d9bc..329fe0547 100644 --- a/application/controllers/Debug.php +++ b/application/controllers/Debug.php @@ -31,7 +31,7 @@ class Debug extends CI_Controller $data['latest_release'] = $this->optionslib->get_option('latest_release'); $data['newer_version_available'] = false; - if ($this->config->item('version_check')) { + if (!$this->config->item('disable_version_check') ?? false) { $this->Update_model->update_check(true); if ($data['latest_release'] && version_compare($data['latest_release'], $data['running_version'], '>')) { $data['newer_version_available'] = true; diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 420a65feb..877f252ef 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -427,7 +427,11 @@ class Update extends CI_Controller { $this->optionslib->update('tle_update', $datetime , 'no'); } - function wavelog_update_check() { + function version_check() { + // set the last run in cron table for the correct cron id + $this->load->model('cron_model'); + $this->cron_model->set_last_run($this->router->class . '_' . $this->router->method); + $this->load->model('Update_model'); $this->Update_model->update_check(); } diff --git a/application/migrations/219_add_version_check_to_cron.php b/application/migrations/219_add_version_check_to_cron.php index d2a7086d4..aa414ff6b 100644 --- a/application/migrations/219_add_version_check_to_cron.php +++ b/application/migrations/219_add_version_check_to_cron.php @@ -3,14 +3,14 @@ defined('BASEPATH') or exit('No direct script access allowed'); class Migration_add_version_check_to_cron extends CI_Migration { public function up() { - if ($this->chk4cron('version_check') == 0) { + if ($this->chk4cron('update_version_check') == 0) { $data = array( array( - 'id' => 'version_check', + 'id' => 'update_version_check', 'enabled' => '0', 'status' => 'pending', 'description' => 'Check for new Wavelog releases', - 'function' => 'index.php/update/wavelog_update_check', + 'function' => 'index.php/update/version_check', 'expression' => '45 4 * * *', 'last_run' => null, 'next_run' => null @@ -20,8 +20,8 @@ class Migration_add_version_check_to_cron extends CI_Migration { } public function down() { - if ($this->chk4cron('version_check') > 0) { - $this->db->query("delete from cron where id='version_check'"); + if ($this->chk4cron('update_version_check') > 0) { + $this->db->query("delete from cron where id='update_version_check'"); } } diff --git a/application/models/Update_model.php b/application/models/Update_model.php index cfc4a5bc5..7b432932b 100644 --- a/application/models/Update_model.php +++ b/application/models/Update_model.php @@ -291,14 +291,18 @@ class Update_model extends CI_Model { } function update_check($silent = false) { - if ($this->config->item('version_check')) { + if (!$this->config->item('disable_version_check') ?? false) { $running_version = $this->optionslib->get_option('version'); $latest_release = $this->wavelog_latest_release(); + $this->set_latest_release($latest_release); if (version_compare($latest_release, $running_version, '>')) { if (!$silent) { print __("Newer release available:")." ".$latest_release; } - $this->set_latest_release($latest_release); + } else { + if (!$silent) { + print __("You are running the latest version."); + } } } } diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 2510cb254..5da962015 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -58,10 +58,10 @@ function echo_table_col($row, $name) { = __("You need to upgrade your PHP version. Minimum version is 7.4. Your version is") . ' ' . PHP_VERSION . '.';?> - session->userdata('user_type') == 99) && $this->config->item('version_check') && $this->optionslib->get_option('latest_release')) { ?> + session->userdata('user_type') == 99) && !($this->config->item('disable_version_check') ?? false) && $this->optionslib->get_option('latest_release')) { ?> optionslib->get_option('latest_release'), $this->optionslib->get_option('version'), '>')) { ?>