mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding fix for Controller::paginate() when default model is loaded from a plugin (Ticket #3660)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6098 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ba59fad873
commit
00dc6dedb5
2 changed files with 20 additions and 1 deletions
|
@ -876,7 +876,12 @@ class Controller extends Object {
|
|||
if (isset($this->{$this->modelClass})) {
|
||||
$object = $this->{$this->modelClass};
|
||||
} else {
|
||||
$object = $this->{$this->uses[0]};
|
||||
if (strpos($this->uses[0], '.') !== false) {
|
||||
list($plugin, $className) = explode('.', $this->uses[0]);
|
||||
$object = $this->{$className};
|
||||
} else {
|
||||
$object = $this->{$this->uses[0]};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,5 +77,19 @@ class ControllerTest extends CakeTestCase {
|
|||
|
||||
unset($Controller);
|
||||
}
|
||||
|
||||
function testPaginate() {
|
||||
$Controller =& new Controller();
|
||||
$Controller->uses = array('ControllerPost', 'ControllerComment');
|
||||
$Controller->passedArgs[] = '1';
|
||||
$Controller->params['url'] = array();
|
||||
$Controller->constructClasses();
|
||||
$Controller->modelClass = null;
|
||||
|
||||
$Controller->uses[0] = 'Plugin.ControllerPost';
|
||||
$results = Set::extract($Controller->paginate(), '{n}.ControllerPost.id');
|
||||
$this->assertEqual($results, array(1, 2, 3));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue