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

[6.x] Only restore common relations #32613

Merged
merged 4 commits into from Apr 30, 2020
Merged

[6.x] Only restore common relations #32613

merged 4 commits into from Apr 30, 2020

Conversation

taylorotwell
Copy link
Member

@taylorotwell taylorotwell commented Apr 30, 2020

Fixes #26126

We only want to restore relationships that are common amongst all models in the collection. Otherwise there will be errors be attempting to restore the collection.

One downside to this PR could be potential performance implications of getting the queueable relationships for each model in the collection. I did this in a collection of about 1000 models and it took 0.70ms on my local machine.

@GrahamCampbell GrahamCampbell changed the title Only restore common relations [6.x] Only restore common relations Apr 30, 2020
@taylorotwell taylorotwell merged commit dcaf8a8 into 6.x Apr 30, 2020
@GrahamCampbell GrahamCampbell deleted the issue-26126 branch April 30, 2020 21:55
@oleksiyPetlyuk
Copy link

There is an error with array_intersect when ...$this->map->getQueueableRelations()->all() returns less then two arrays

@driesvints
Copy link
Member

@oleksiyPetlyuk this should be fixed in the latest release.

@taylorotwell
Copy link
Member Author

What exactly is getQueueableRelations returning for you?

@GC-Mark
Copy link

GC-Mark commented May 5, 2020

We are also seeing ErrorException: array_intersect(): at least 2 parameters are required, 1 given in Illuminate/Database/Eloquent/Collection.php:579

For us, getQueueableRelations is returning this...

$relations = $this->map->getQueueableRelations()->all();

dump($relations);
array:1 [
  0 => array:1 [
    0 => "account"
  ]
]

Hope that helps

@taylorotwell
Copy link
Member Author

OK Thanks that is helpful. Fixing now.

@oleksiyPetlyuk
Copy link

oleksiyPetlyuk commented May 5, 2020

Im using Laravel 6.18.12
For me getQueueableRelations is returning
array:1 [ 0 => array:1 [ 0 => "model" ] ]

@taylorotwell
Copy link
Member Author

Fixed on 6.18.13.

@taylorotwell
Copy link
Member Author

Fixed on 7.10.1.

@GC-Mark
Copy link

GC-Mark commented May 5, 2020

Installed and fix confirmed in 7.10.1 👍

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.

None yet

4 participants