From 2054430a6e5c7553fe7b1400ba6df924fa3e8c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:02:43 +0100 Subject: [PATCH] Validate Scheduler CronExpression Inspired by https://github.com/laravel/framework/pull/53961#discussion_r1890404965 --- src/Illuminate/Console/Scheduling/ManagesFrequencies.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php b/src/Illuminate/Console/Scheduling/ManagesFrequencies.php index d974a91b769..06e903de76e 100644 --- a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php +++ b/src/Illuminate/Console/Scheduling/ManagesFrequencies.php @@ -2,6 +2,7 @@ namespace Illuminate\Console\Scheduling; +use Cron\CronExpression; use Illuminate\Support\Carbon; use InvalidArgumentException; @@ -15,6 +16,10 @@ trait ManagesFrequencies */ public function cron($expression) { + if (!CronExpression::isValidExpression()) { + throw new InvalidArgumentException("The expression [$expression] is not a valid cron expression."); + } + $this->expression = $expression; return $this;