-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Exception when deserializing FailedJob model #23168
Comments
Your steps to reproduce isn't a complete code snippet we can use to reproduce it. Could you provide minimal working example we can use for this purpose? |
Complete function I use in a Controller namen
FailedJob ist just an "empty" model refering to the table created by using
If you need more information, just ask. |
It looks to me that this issue is actually called from Jobs queued in Laravel 5.5 that are run after the 5.6 update (due to a delay on the queued job). I'm not certain if it only happens if the queued model had a relationship or not, but we were seeing this after our update from 5.5 to 5.6 each time a job was attempted to be processed by the queue. |
It appears that jobs with relations queued in Laravel 5.6 have a "relations" property serialized with them, while in 5.5 they didn't. Thus when jobs queued in 5.5 are parsed in 5.6, this Exception is thrown. |
I have tried to verify your assumption by clearing the failed jobs table and "creating" some new ones. Everything seems to work fine now. Thanks for the support, closing the issue now. |
For anyone coming back to this issue, I was able to get all of my jobs to go through by following these steps. I made the modifications on my production server and then ran the jobs through. After I did that, I put everything back to how it ships with Laravel.
/**
* Set the relationships that should be eager loaded.
*
* @param mixed $relations
* @return $this
*/
public function with($relations)
{
if (is_null($relations)) {
$relations = [];
}
$eagerLoad = $this->parseWithRelations(is_string($relations) ? func_get_args() : $relations);
$this->eagerLoad = array_merge($this->eagerLoad, $eagerLoad);
return $this;
}
To explain this, when the jobs got queued in L5.5, the Please note: any new jobs dispatched in L5.6 will continue to work as expected and it will automatically add that new Hope this helps anyone looking at this issue. |
This sounds like something you should send a PR for. There will be many future upgrades of 5.5 to a newer version, and they may want their jobs to work... |
@sisve I don't believe @taylorotwell would want this in the core as it is a temporary issue that only happens if you queued up jobs in L5.5 for a later date and have upgraded to L5.6 since then. It will go away once all of the jobs run. |
I'm pretty sure this should be in the core. Even if it only happens when people upgrade; people will still upgrade from 5.5 to a newer release for another 2+ years since 5.5 is a LTS release. Sure, maybe we shouldn't add a null-check to the Builder::with() method. How about using
|
@sisve That fix makes a lot of sense to me. I ended up adding a temporary hook to my deploy script to replace that file for the next few weeks to make sure no < 5.6 queued jobs are throwing exceptions. A fix in the actual framework would be welcome by me! |
@vicgonvt This is your chance to get the Contributor flag! ;) |
Submitted the PR in #23287 |
Info:
If you believe this is not something for the issue tracker, please close this issue and tell me!
Description:
I used to deserialize the FailedJob model in the failed_jobs table to display the filename the Job was processing. After upgrading to Laravel 5.5 to 5.6 this produces an Exception. I added the code I use below.
Steps To Reproduce:
Results in
Type error: Argument 1 passed to Illuminate\Database\Eloquent\Builder::parseWithRelations() must be of the type array, null given, called in /var/www/html/oma/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php on line 1034
Symfony\Component\Debug\Exception\FatalThrowableError
…/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php 1075
Illuminate\Database\Eloquent\Builder parseWithRelations
…/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php 1034
Illuminate\Database\Eloquent\Builder with
…/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php 389
Illuminate\Database\Eloquent\Model load
…/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php 85
App\Jobs\SendProductCoreData restoreModel
…/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php 55
App\Jobs\SendProductCoreData getRestoredPropertyValue
…/vendor/laravel/framework/src/Illuminate/Queue/SerializesModels.php 45
App\Jobs\SendProductCoreData __wakeup
[internal]0
unserialize
…/app/Http/Controllers/UploadController.php 204
The text was updated successfully, but these errors were encountered: