X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FDB%2FBackgroundJob.pm;h=b7b907bb77026f6144d7a602c29985a89ab814a1;hb=e5f571cf1b7b61910b5f1b6f50188a9568a274e9;hp=18f8e428fabbd5ae665964b224dbbff895781d60;hpb=3be85e174a63158503c333e7f0682abfc969bf8b;p=kivitendo-erp.git diff --git a/SL/DB/BackgroundJob.pm b/SL/DB/BackgroundJob.pm index 18f8e428f..b7b907bb7 100644 --- a/SL/DB/BackgroundJob.pm +++ b/SL/DB/BackgroundJob.pm @@ -13,6 +13,15 @@ use SL::DB::BackgroundJobHistory; use SL::BackgroundJob::Test; use SL::System::Process; +__PACKAGE__->before_save('_before_save_set_next_run_at'); + +sub _before_save_set_next_run_at { + my ($self) = @_; + + $self->update_next_run_at if !$self->next_run_at; + return 1; +} + sub update_next_run_at { my $self = shift; @@ -81,7 +90,7 @@ sub validate { } eval { - DateTime::Event::Cron->new_from_cron($self->cron_spec)->next(DateTime->now_local); + DateTime::Event::Cron->new_from_cron($self->cron_spec || '* * * * *')->next(DateTime->now_local); 1; } or push @errors, $::locale->text('The execution schedule is invalid.');