From 13bb263bfe0d8db53fc559876d063dbb5fa71e31 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 12 Sep 2024 16:23:58 +0200 Subject: [PATCH] Add version check to cron manager --- application/config/migration.php | 2 +- .../219_add_version_check_to_cron.php | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 application/migrations/219_add_version_check_to_cron.php diff --git a/application/config/migration.php b/application/config/migration.php index 85cf84b36..e248999d5 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 217; +$config['migration_version'] = 219; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/219_add_version_check_to_cron.php b/application/migrations/219_add_version_check_to_cron.php new file mode 100644 index 000000000..d2a7086d4 --- /dev/null +++ b/application/migrations/219_add_version_check_to_cron.php @@ -0,0 +1,33 @@ +chk4cron('version_check') == 0) { + $data = array( + array( + 'id' => 'version_check', + 'enabled' => '0', + 'status' => 'pending', + 'description' => 'Check for new Wavelog releases', + 'function' => 'index.php/update/wavelog_update_check', + 'expression' => '45 4 * * *', + 'last_run' => null, + 'next_run' => null + )); + $this->db->insert_batch('cron', $data); + } + } + + public function down() { + if ($this->chk4cron('version_check') > 0) { + $this->db->query("delete from cron where id='version_check'"); + } + } + + function chk4cron($cronkey) { + $query = $this->db->query("select count(id) as cid from cron where id=?",$cronkey); + $row = $query->row(); + return $row->cid ?? 0; + } +}