-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
HandleModelNotFound() method uses displayName() method of the job as class name #54502
Comments
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
@JochemLettink I tried to reproduce the issue but I was unable to, can you please check the code bellow and provide more information
|
@achrafAa Thanks for your response! I tested your code and noticed a few differences:
The bug is that the exception is still logged because Ultimately, while the specific ModelNotFoundException isn’t thrown, the job isn’t silently deleted either—it goes through the failure lifecycle. This should not happen because From the logs, it appears that the job has thrown the exception, but this is not the case. I will update the ticket description to match this. Thanks for your input!
|
This will be resolved in Laravel 12. |
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 totrue
, aModelNotFoundException
is still logged and the job is going through thefail()
lifecycle if the model is deleted in the meantime.This happens because the
handleModelNotFound
() method inCallQueueHandler
resolves the job name using$class = $job->resolveName();
, which callsJobName::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
$deleteWhenMissingModels
property set totrue
The text was updated successfully, but these errors were encountered: