Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Allow any kind of whitespace in cron expressions #44110

Merged
merged 4 commits into from
Sep 13, 2022
Merged

[9.x] Allow any kind of whitespace in cron expressions #44110

merged 4 commits into from
Sep 13, 2022

Conversation

onlime
Copy link
Contributor

@onlime onlime commented Sep 13, 2022

Be more tolerant on task scheduling cron expression spacing, allowing any whitespace as separator. Previously, only a single space was allowed as separator, resulting in the following exception if e.g. a tab was used instead:

$schedule->command('foobar:sample-task')->cron('5,35 *	* * *'); // "5,35 *\t* * *"
$ pa schedule:list

   ErrorException 

  Undefined array key 4

  at vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleListCommand.php:165
    161▕     {
    162▕         $expressions = explode(' ', $expression);
    163▕ 
    164▕         return collect($spacing)
  ➜ 165▕             ->map(fn ($length, $index) => str_pad($expressions[$index], $length))
    166▕             ->implode(' ');
    167▕     }
    168▕ 
    169▕     /**

Copy link
Member

@jbrooksuk jbrooksuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to man crontab

The fields may be separated by spaces or tabs.

@taylorotwell taylorotwell merged commit 43948d0 into laravel:9.x Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants