diff --git a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php b/src/Illuminate/Console/Scheduling/ManagesFrequencies.php index 93555b76f124..f13920dec63f 100644 --- a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php +++ b/src/Illuminate/Console/Scheduling/ManagesFrequencies.php @@ -546,7 +546,7 @@ public function timezone($timezone) */ protected function spliceIntoPosition($position, $value) { - $segments = explode(' ', $this->expression); + $segments = preg_split("/\s+/", $this->expression); $segments[$position - 1] = $value; diff --git a/src/Illuminate/Console/Scheduling/ScheduleListCommand.php b/src/Illuminate/Console/Scheduling/ScheduleListCommand.php index cb4236a9dd10..04ca6a09bbec 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleListCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleListCommand.php @@ -145,7 +145,7 @@ public function handle(Schedule $schedule) */ private function getCronExpressionSpacing($events) { - $rows = $events->map(fn ($event) => array_map('mb_strlen', explode(' ', $event->expression))); + $rows = $events->map(fn ($event) => array_map('mb_strlen', preg_split("/\s+/", $event->expression))); return collect($rows[0] ?? [])->keys()->map(fn ($key) => $rows->max($key)); } @@ -159,7 +159,7 @@ private function getCronExpressionSpacing($events) */ private function formatCronExpression($expression, $spacing) { - $expressions = explode(' ', $expression); + $expressions = preg_split("/\s+/", $expression); return collect($spacing) ->map(fn ($length, $index) => str_pad($expressions[$index], $length)) diff --git a/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php b/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php index 73b8c247e242..64d024a37fdd 100644 --- a/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php +++ b/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php @@ -34,6 +34,8 @@ public function testDisplaySchedule() $this->schedule->command('inspire')->twiceDaily(14, 18); $this->schedule->command('foobar', ['a' => 'b'])->everyMinute(); $this->schedule->job(FooJob::class)->everyMinute(); + $this->schedule->command('inspire')->cron('0 9,17 * * *'); + $this->schedule->command('inspire')->cron("0 10\t* * *"); $this->schedule->call(fn () => '')->everyMinute(); $closureLineNumber = __LINE__ - 1; @@ -45,6 +47,8 @@ public function testDisplaySchedule() ->expectsOutput(' 0 14,18 * * * php artisan inspire ........ Next Due: 14 hours from now') ->expectsOutput(' * * * * * php artisan foobar a='.ProcessUtils::escapeArgument('b').' ... Next Due: 1 minute from now') ->expectsOutput(' * * * * * Illuminate\Tests\Integration\Console\Scheduling\FooJob Next Due: 1 minute from now') + ->expectsOutput(' 0 9,17 * * * php artisan inspire ......... Next Due: 9 hours from now') + ->expectsOutput(' 0 10 * * * php artisan inspire ........ Next Due: 10 hours from now') ->expectsOutput(' * * * * * Closure at: '.$closureFilePath.':'.$closureLineNumber.' Next Due: 1 minute from now'); }