Fixed issue where extending from another entity causes infinite recur…#17
Fixed issue where extending from another entity causes infinite recur…#17jeremyharris merged 3 commits intojeremyharris:masterfrom redscode:master
Conversation
| $this->_unsetProperties[] = $prop; | ||
| } | ||
| return parent::unsetProperty($property); | ||
| return Entity::unsetProperty($property); |
There was a problem hiding this comment.
Missing blank line before return statement
Codecov Report
@@ Coverage Diff @@
## master #17 +/- ##
=======================================
Coverage 100% 100%
Complexity 18 18
=======================================
Files 1 1
Lines 44 44
=======================================
Hits 44 44
Continue to review full report at Codecov.
|
…sion when lazy loading
|
Forgive my ignorance, but how the heck does this even work? Entity doesn't have a static I think |
|
Well, Entity or EntityTrait doesn't have a static get either so anything that extends those wouldn't have it unless it's added manually. I was following the logic that the LazyLoadTrait would be applied to a class that extends Entity. So by parent:: we are really accessing Entity:: I tried using self:: and static:: and encountered the same problem. Only Entity:: remedies the problem. To replicate you need to extend from an existing entity that uses the LazyLoadTrait (both classes have to use the trait). You also need to create a Table class for the new entity that is set to the original models table. |
|
My confusion was how At any rate, I'll test it out, thanks for the zip file! |
|
@redscode while I look into this, you can fix your issue by only including the trait in the base class. The child class will inherit the lazy loading abilities (I probably should update the documentation to better explain this). |
|
Okay, I learned something new today! I was trying to understand why So yay, thanks for reporting this bug and for teaching me something new :) |
| protected function &_parentGet($property) | ||
| { | ||
| return parent::get($property); | ||
| return Entity::get($property); |
There was a problem hiding this comment.
I know. When I asked about it my mind was blown. I'm happy to still be learning :)
Fixed issue where extending from another entity causes infinite recursion when lazy loading.