Skip to content

[12.x] Fix prevent group attribute pollution in schedule #56677

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

Merged
merged 2 commits into from
Aug 17, 2025

Conversation

People-Sea
Copy link
Contributor

Fixed: #56497

scheduling logic

Carbon::setTestNow(Carbon::create(2024, 1, 1, 8, 05, 0));
dump('Current time: '.Carbon::now()->toDateTimeString());
Schedule::days([1, 2, 3, 4, 5, 6])->group(function () {
    Schedule::between('07:00', '08:00')->group(function () {
        Schedule::call(Task1::class)->everyMinute();
        Schedule::call(Task2::class)->everyFiveMinutes();
    });

    Schedule::call(Task3::class)->at('08:05');
});

before

root@PeopleSea-PC:/laravel-bug-report# php artisan schedule:run
"Current time: 2024-01-01 08:05:00" // routes/console.php:12

   INFO  No scheduled commands are ready to run.  

after

root@PeopleSea-PC:/laravel-bug-report# php artisan schedule:run
"Current time: 2024-01-01 08:05:00" // routes/console.php:12

  2024-01-01 08:05:00 Running [App\Jobs\Task3] .......................................32.63ms DONE

Solution approach:

It is correct that attributes are inherited when group is nestedly called. However, if filters are declared in the child group, it will directly change the top-level group. Therefore, clone should be used to prevent filters from causing contamination.

Use clone to ensure group attributes are isolated and not affected by reference issues.

Fixes: laravel#56497
@taylorotwell taylorotwell merged commit 7796b9b into laravel:12.x Aug 17, 2025
62 checks passed
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.

Issue with task scheduler grouping
2 participants