Merge pull request #4990 from esarbanis/cron-validation-on-update

fix: validate cron expression in Scheduled Task update
This commit is contained in:
Andras Bacsai
2025-01-28 11:00:53 +01:00
committed by GitHub

View File

@@ -77,6 +77,10 @@ class Show extends Component
{
if ($toModel) {
$this->validate();
$isValid = validate_cron_expression($this->frequency);
if (! $isValid) {
throw new \Exception('Invalid Cron / Human expression.');
}
$this->task->enabled = $this->isEnabled;
$this->task->name = str($this->name)->trim()->value();
$this->task->command = str($this->command)->trim()->value();
@@ -109,7 +113,7 @@ class Show extends Component
$this->syncData(true);
$this->dispatch('success', 'Scheduled task updated.');
} catch (\Exception $e) {
return handleError($e);
return handleError($e, $this);
}
}