jeremyharris / cakephp-lazyload

A lazy loader for CakePHP entities.
MIT License
61 stars 10 forks source link

Query formatResults breaks lazy loading in certain cases #6

Closed dakota closed 7 years ago

dakota commented 8 years ago

Took me far to long to track this one down. I don't believe the problem is a LazyLoader problem, rather something in CakePHP itself, but LazyLoader allows it to manifest itself.

Basically, if you attempt to lazy load an association that does not have anything to load (For example, where the child row has been deleted) AND a behaviour, or callback exists on the target table that adds a result formatter to the query things break badly. It enters an infinite loop trying to load the association. I've only tested belongsTo associations, but I think hasOne might show similar symptoms.

jeremyharris commented 7 years ago

@dakota I know it's been a while, but I went ahead and checked this out again after some recent fixes and your PR merge into cake. I merged lazyload's master into your branch and your test case passes 👍

Would you be interested in rebasing this onto master? If not I can push the test case in separately at a later date.

Thanks for digging into this!

jeremyharris commented 7 years ago

Added a test case for this in 2.0.1 and 1.0.3