Skip to content

Conversation

@moshe-autoleadstar
Copy link
Contributor

When using Event::defer without specifying specific classes to defer, there are some listeners in many packages that break. For example:

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Spatie\LaravelIgnition\Recorders\QueryRecorder\QueryRecorder::record(), 0 passed in /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 488 and exactly 1 expected in /var/www/html/vendor/spatie/laravel-ignition/src/Recorders/QueryRecorder/QueryRecorder.php:37
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(488): Spatie\LaravelIgnition\Recorders\QueryRecorder\QueryRecorder->record()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(315): Illuminate\Events\Dispatcher->{closure:Illuminate\Events\Dispatcher::makeListener():483}()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(295): Illuminate\Events\Dispatcher->invokeListeners()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(826): Illuminate\Events\Dispatcher->dispatch()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(363): Illuminate\Events\Dispatcher->defer()
//...

This happens because we are collecting the deferredEvents from the func_get_args(). But, right above that, we are changing the "called arguments", reassigning the variables to their parsed counterparts.
This PR renames the parsed variable names so as not to interfere with the func_get_args() and to collect the raw/unparsed arguments for later dispatching.

@taylorotwell taylorotwell merged commit 5d1b81d into laravel:12.x Oct 21, 2025
66 of 68 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.

2 participants