-
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
[6.x] Fix missing statement preventing deletion #33648
Conversation
The delete method was missing a statement which prevented the deletion of many to many polymorphic pivot models.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test covering this?
@@ -45,6 +45,10 @@ protected function setKeysForSaveQuery(Builder $query) | |||
*/ | |||
public function delete() | |||
{ | |||
if (isset($this->attributes[$this->getKeyName()])) { | |||
return (int) parent::delete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this cast needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, To be honest, I don't know.
I just took the code from the laravel 7.x branch since the use case worked there.
Sorry, I am a beginner and I really don't know how to write tests |
@taylorotwell It looks like the original PR was #32421. I'm not sure why 7.x was targetted instead of 6.x. The author didn't explain their choice of branch, and it wasn't discussed. |
Yes that's the same problem I had |
So, this is just a bug fix backport? |
@taylorotwell Yes, I think so |
I still don't follow why there is an int cast. |
The code comes originally from the AsPivot trait |
Maybe in case to make sure what this function is returning is |
The MorphPivot delete method was missing a statement which prevented the deletion of many to many polymorphic custom pivot models.
This pull request is related to #33647 and should fix the issue.