From aa0b7977bba64fef72e9a54443ae34981910dc5b Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 21 Mar 2021 10:49:23 -0700 Subject: [PATCH] Fix error spam in logs due to missing cron month --- app/Models/Schedule.php | 3 +- ...n_month_field_to_have_value_if_missing.php | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php index 432f4d5f8..240873cac 100644 --- a/app/Models/Schedule.php +++ b/app/Models/Schedule.php @@ -122,13 +122,14 @@ class Schedule extends Model * Returns the schedule's execution crontab entry as a string. * * @return \Carbon\CarbonImmutable + * @throws \Exception */ public function getNextRunDate() { $formatted = sprintf('%s %s %s %s %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week); return CarbonImmutable::createFromTimestamp( - CronExpression::factory($formatted)->getNextRunDate()->getTimestamp() + (new CronExpression($formatted))->getNextRunDate()->getTimestamp() ); } diff --git a/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php b/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php new file mode 100644 index 000000000..63448c220 --- /dev/null +++ b/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php @@ -0,0 +1,31 @@ +