Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do type checks when looking for models in Controller::$uses.
This solves issues with models not being added when $uses = true. Fixes #3774
- Loading branch information
Showing
2 changed files
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
efd86a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something changed in the current master branch and broke existing apps.
I suspect this commit. But I could also be wrong and the issue could be further back..
If you got in your AppController:
Until recently, all other controller's $this->modelClass was correctly the model class of this controller.
Or at least pagination worked correctly.
Now it's always "Country", as the app model uses declares it, and $this->paginate() without arguments breaks.
In my case a plugin controller (RatingsController extends RatingsAppController extends AppController).
Even a manual
public $uses = array('Ratings.Rating');
does not fix this!Maybe the controller should array_unshift its modelClass in app uses to avoid this BC breaking?
efd86a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dereuromark I think that is correct. It should always be the first (or only) model you declare.
efd86a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
$uses
is defined in mergeParent the default$modelClass
is added to $uses using array_unshift.efd86a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really confused as to how this change could have broken what you're describing. Would the following reproduce the issue?