cakephp/cakephp — pull request #2746 by lorenzo (2014-01-30 21:34:24+00:00)
Title: 3.0 refactor contain

Give the problems we found with queries being executed twice would run the contain logic twice too, I thought we needed to refactor the code to allow some flexibility for a more durable fix. Also, I figured that most of the Query class was dealing with non-query stuff in order to eager load associations, making this class difficult to read.

This change extracts all the logic for eager loading associations into its own class, the query object now uses instances of this objects to delegate all eager loading tasks to it. Additionally, I removed the possibility of directly editing the containments ArrayObject instance from outside the query class, this was a bad idea in hindsight.