cakephp/cakephp — pull request #700 by arekdziki (2012-06-26 09:06:27+00:00)
Title: This make possible to create "join" using associated models. 

Scenario: There is relationship: Post belongsTo User. Now, for some weird reason, You want to create custom "join" to "bars" table inside Post model basing on condition User.bar_id = Bar.id.
Post->find('first', array('joins' => array('type' => 'LEFT', 'table' => 'bars', 'alias' => 'Bar', 'conditions' => array('User.bar_id = Bar.id'))));

Then internally: first in join array is join from params, and then goes all associations from belongsTo and hasOne.
In mysql joins order matters, and there is a bug in query.

I'm using join key in 'finds' form time to time, and every time it is necessary to set recursive = -1 and setting all associations in low level.

This fix is resolving problem, by changing joins order.