Skip to content
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

[5.8] 5.8.29 tagged today breaks queue deserializing with Model::newCollection() #29196

Merged
merged 2 commits into from
Jul 17, 2019

Conversation

tw99
Copy link
Contributor

@tw99 tw99 commented Jul 16, 2019

This change pull request #29196 breaks queued jobs using SerializesModels that expect a custom collection. The above changes return an EloquentCollection when unserialized regardless of the model overriding newCollection.

Example:

<?php

namespace App\Jobs;

use App\Models\Collections\PostsCollection;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class DoSomethingToPosts extends Job implements ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    public $posts;

    public function __construct(PostsCollection $posts)
    {
        $this->posts = $posts;
    }

    public function handle()
    {
        // This object is now \Illuminate\Database\Eloquent\Collection,
        // not a PostsCollection instance.
        $this->posts;
    }
}

Thanks @derekmd for the tips on this PR

@tw99 tw99 force-pushed the Fix-queue-restoring-custom-collections branch 3 times, most recently from 0422925 to 130c5b7 Compare July 16, 2019 22:12
@tw99 tw99 force-pushed the Fix-queue-restoring-custom-collections branch from 130c5b7 to 4525df0 Compare July 16, 2019 22:15
@tw99 tw99 changed the title Fix queue jobs restoring custom collection Fix queue jobs restoring custom Eloquent collection Jul 16, 2019
@tw99 tw99 changed the title Fix queue jobs restoring custom Eloquent collection 5.8.29 tagged today breaks queue deserializing with Model::newCollection() Jul 16, 2019
@driesvints
Copy link
Member

Why aren’t we filtering the original collection instead? 🤔

@driesvints driesvints changed the title 5.8.29 tagged today breaks queue deserializing with Model::newCollection() [5.8] 5.8.29 tagged today breaks queue deserializing with Model::newCollection() Jul 17, 2019
@taylorotwell taylorotwell merged commit 1f74cc1 into laravel:5.8 Jul 17, 2019
@tw99 tw99 deleted the Fix-queue-restoring-custom-collections branch August 20, 2019 17:35
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.

3 participants