diff --git a/application/controllers/Cron.php b/application/controllers/Cron.php index 2c3dd4d9d..f7a3c5a18 100644 --- a/application/controllers/Cron.php +++ b/application/controllers/Cron.php @@ -51,8 +51,12 @@ class cron extends CI_Controller { if ($cron->enabled == 1) { // calculate the crons expression - $this->load->library('CronExpression'); - $cronjob = CronExpression::parse($cron->expression); // Verwende die statische Methode der CronExpression-Klasse + $data = array( + 'expression' => $cron->expression, + 'timeZone' => null + ); + $this->load->library('CronExpression', $data); + $cronjob = $this->cronexpression; $dt = new DateTime(); $isdue = $cronjob->isMatching($dt); @@ -101,6 +105,7 @@ class cron extends CI_Controller { // 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); } + $this->cronexpression = null; } } } diff --git a/application/libraries/CronExpression.php b/application/libraries/CronExpression.php index 13d56f7a9..439f74883 100644 --- a/application/libraries/CronExpression.php +++ b/application/libraries/CronExpression.php @@ -86,14 +86,14 @@ class CronExpression { /** * @param string $expression a cron expression, e.g. "* * * * *" - * @param DateTimeZone|null $timeZone time zone object + * @param DateTimeZone|null $timeZone time zone objectstring $expression, DateTimeZone $timeZone = null */ - public function __construct(string $expression, DateTimeZone $timeZone = null) { - $this->timeZone = $timeZone; - $this->expression = $expression; + public function __construct($data) { + $this->timeZone = $data['timeZone']; + $this->expression = $data['expression']; try { - $this->registers = $this->parse($expression); + $this->registers = $this->parse($data['expression']); } catch (Exception $e) { $this->registers = null; }