You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Illuminate\Database\Eloquent\Model::bootTraits() method executes the same bootXyzTrait method multiple times if the model uses two (or more) traits with the same base name.
This is simply resolvable by renaming the second trait but isn't cool if you want to extend a package trait for example.
Create a model (App\User) with a trait (App\Traits\HasEmail) which uses a trait (Developer\Package\Traits\HasEmail) with a trait boot method (bootHasEmail).
Thanks for this fix. Will this get a backport to older versions?
And thanks for the fast fix - wrote this just as a copy of the linked issue on the road.
It's independent of versions so far I know.
Description:
The
Illuminate\Database\Eloquent\Model::bootTraits()
method executes the samebootXyzTrait
method multiple times if the model uses two (or more) traits with the same base name.This is simply resolvable by renaming the second trait but isn't cool if you want to extend a package trait for example.
Steps To Reproduce:
spatie/laravel-activitylog#392
Create a model (
App\User
) with a trait (App\Traits\HasEmail
) which uses a trait (Developer\Package\Traits\HasEmail
) with a trait boot method (bootHasEmail
).If the trait adds oberserver or other logic that should run just once it will run these things two times.
The text was updated successfully, but these errors were encountered: