-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Description
Laravel Version
11.41.3
PHP Version
8.4.3
Database Driver & Version
Mysql 8.0.40 - Debian 12
Description
When pushing a job to the database queue using the displayName()
method to set a custom display name in the queue worker, and with the $deleteWhenMissingModels
property set to true
, a ModelNotFoundException
is still logged and the job is going through the fail()
lifecycle if the model is deleted in the meantime.
This happens because the handleModelNotFound
() method in CallQueueHandler
resolves the job name using $class = $job->resolveName();
, which calls JobName::resolve($this->getName(), $this->payload());
This method returns the displayName, which is not a valid class name because the displayName is changed.
As a result, ReflectionClass fails to reflect the class, causing the system to incorrectly determine that shouldDelete is false, leading to running the fail() lifecycle of the job in stead of quietly discard the job.
Steps To Reproduce
- Create a database job with the
$deleteWhenMissingModels
property set totrue
- Add a model to the constructor of the job
- Add an custom displayName() method to the job that returns an non existing class
- Create a test that creates the model, dispatches the job and delete the model before running the (DB) queue worker.
- Make sure to run the test expecting no errors to be logged.