From a16b70900bf33649cff602543217ab2e701621a9 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Tue, 23 Apr 2024 10:50:57 +0200 Subject: [PATCH] added some todo comments --- application/controllers/Cron.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/application/controllers/Cron.php b/application/controllers/Cron.php index 92f975099..dd541cd5f 100644 --- a/application/controllers/Cron.php +++ b/application/controllers/Cron.php @@ -2,6 +2,9 @@ require_once './src/Cron/vendor/autoload.php'; +// TODO +// Add 'add' / 'edit' functions to be able to add/edit the crons in the cron manager view + class cron extends CI_Controller { function __construct() { @@ -38,6 +41,8 @@ class cron extends CI_Controller // This is the main function, which handles all crons, runs them if enabled and writes the 'next run' timestamp to the database + // TODO Add an API Key to the cronjob to improve security? + $this->load->model('cron_model'); $crons = $this->cron_model->get_crons(); @@ -52,7 +57,10 @@ class cron extends CI_Controller $isdue = $cronjob->isDue(); if ($isdue == true) { $isdue_result = 'true'; - echo "CRON: ".$cron->id." -> is due: ".$isdue_result."\n"; + + // TODO Add log_message level debug here to have logging for the cron manager + + echo "CRON: ".$cron->id." -> is due: ".$isdue_result."\n"; echo "CRON: ".$cron->id." -> RUNNING...\n"; $url = base_url().$cron->function; @@ -67,29 +75,29 @@ class cron extends CI_Controller if ($crun !== false) { echo "CRON: ".$cron->id." -> CURL Result: ".$crun."\n"; + + // TODO Proper testing if '!== false' is enough for all functions. + // TODO Make Curl Result available in Cron Manager view? + } else { echo "ERROR: Something went wrong with ".$cron->id."\n"; + + // TODO Add a flag or some kind of warning for the cron manager view? + } } else { $isdue_result = 'false'; echo "CRON: ".$cron->id." -> is due: ".$isdue_result."\n"; } - - $next_run = $cronjob->getNextRunDate(date('Y-m-d H:i:s'))->format('Y-m-d H:i:s'); echo "CRON: ".$cron->id." -> Next Run: ".$next_run."\n"; $this->cron_model->set_next_run($cron->id,$next_run); - - - - - } else { echo 'CRON: '.$cron->id." is disabled.\n"; - // set the next_run timestamp to null to indicate that this cron is disabled + // Set the next_run timestamp to null to indicate in the view/database that this cron is disabled $this->cron_model->set_next_run($cron->id,null); }