mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding 'type' key to both sets of query calls in Controller::paginate(), fixes #5441
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7680 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2cb2ca554c
commit
4b8acf4647
2 changed files with 14 additions and 2 deletions
|
@ -985,9 +985,12 @@ class Controller extends Object {
|
|||
if (isset($defaults[0])) {
|
||||
$type = array_shift($defaults);
|
||||
}
|
||||
$extra = array_diff_key($defaults, compact(
|
||||
$extra = array_diff_assoc($defaults, compact(
|
||||
'conditions', 'fields', 'order', 'limit', 'page', 'recursive'
|
||||
));
|
||||
if ($type !== 'all') {
|
||||
$extra['type'] = $type;
|
||||
}
|
||||
|
||||
if (method_exists($object, 'paginateCount')) {
|
||||
$count = $object->paginateCount($conditions, $recursive, $extra);
|
||||
|
|
|
@ -493,11 +493,20 @@ class ControllerTest extends CakeTestCase {
|
|||
$Controller->params['url'] = array();
|
||||
$Controller->constructClasses();
|
||||
$Controller->paginate = array(
|
||||
'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id'));
|
||||
'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id')
|
||||
);
|
||||
$result = $Controller->paginate('ControllerPaginateModel');
|
||||
$expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id');
|
||||
$this->assertEqual($Controller->ControllerPaginateModel->extra, $expected);
|
||||
$this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected);
|
||||
|
||||
$Controller->paginate = array(
|
||||
'ControllerPaginateModel' => array('foo', 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id')
|
||||
);
|
||||
$Controller->paginate('ControllerPaginateModel');
|
||||
$expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'type' => 'foo');
|
||||
$this->assertEqual($Controller->ControllerPaginateModel->extra, $expected);
|
||||
$this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected);
|
||||
}
|
||||
/**
|
||||
* testDefaultPaginateParams method
|
||||
|
|
Loading…
Add table
Reference in a new issue