cakephp/cakephp — pull request #5151 by dakota (2014-11-13 11:18:25+00:00)
Title: Fixes #5150

As reported in #5150, some databases don't like including `order by` along with `count(*)`, this is usually not a problem as the `Query::count()` method creates a clean copy of the query which excludes any counts or limits. However, if the query is modified in the beforeFind callback, the count() method will not clean up any added parts.

This PR corrects that issue by triggering beforeFind as part of the clean-up process.