Skip to content

[6.x] Only restore common relations#32613

Merged
taylorotwell merged 4 commits into
6.xfrom
issue-26126
Apr 30, 2020
Merged

[6.x] Only restore common relations#32613
taylorotwell merged 4 commits into
6.xfrom
issue-26126

Conversation

@taylorotwell

@taylorotwell taylorotwell commented Apr 30, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown

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

@driesvints

Copy link
Copy Markdown
Member

@oleksiyPetlyuk this should be fixed in the latest release.

@taylorotwell

Copy link
Copy Markdown
Member Author

What exactly is getQueueableRelations returning for you?

@GC-Mark

GC-Mark commented May 5, 2020

Copy link
Copy Markdown

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
Copy Markdown
Member Author

OK Thanks that is helpful. Fixing now.

@oleksiyPetlyuk

oleksiyPetlyuk commented May 5, 2020

Copy link
Copy Markdown

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

@taylorotwell

Copy link
Copy Markdown
Member Author

Fixed on 6.18.13.

@taylorotwell

Copy link
Copy Markdown
Member Author

Fixed on 7.10.1.

@GC-Mark

GC-Mark commented May 5, 2020

Copy link
Copy Markdown

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.

4 participants