-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Closed
Labels
Description
Laravel Version
11.x
PHP Version
8.3
Database Driver & Version
No response
Description
When $popCallbacks is assigned to the Illuminate\Queue\Worker class and it returns null the JobPopped event is fired with $job value null
Steps To Reproduce
Illuminate\Queue\Worker::$popCallbacks['test'] = function($popJobCallback, $queue) {
return null;
}
- queue:work --name=test
- listen for the event JobPopped
Fix:
In the class Illuminate\Queue\Worker
method getNextJob
Replace:
if (isset(static::$popCallbacks[$this->name])) {
return tap(
(static::$popCallbacks[$this->name])($popJobCallback, $queue),
fn ($job) => $this->raiseAfterJobPopEvent($connection->getConnectionName(), $job)
);
}
with:
if (isset(static::$popCallbacks[$this->name])) {
if (! is_null($job = (static::$popCallbacks[$this->name])($popJobCallback, $queue))) {
$this->raiseAfterJobPopEvent($connection->getConnectionName(), $job);
}
return $job;
}