mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Applying patch from 'SkieDr' to fix custom find type pagination. Removes parameters from exiting paginate(). Test case added.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8137 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
5f4cdf91ac
commit
9491e4632d
2 changed files with 28 additions and 5 deletions
|
@ -1030,6 +1030,14 @@ class Controller extends Object {
|
|||
if (!isset($defaults['conditions'])) {
|
||||
$defaults['conditions'] = array();
|
||||
}
|
||||
|
||||
$type = 'all';
|
||||
|
||||
if (isset($defaults[0])) {
|
||||
$type = $defaults[0];
|
||||
unset($defaults[0]);
|
||||
}
|
||||
|
||||
extract($options = array_merge(array('page' => 1, 'limit' => 20), $defaults, $options));
|
||||
|
||||
if (is_array($scope) && !empty($scope)) {
|
||||
|
@ -1040,12 +1048,7 @@ class Controller extends Object {
|
|||
if ($recursive === null) {
|
||||
$recursive = $object->recursive;
|
||||
}
|
||||
$type = 'all';
|
||||
|
||||
if (isset($defaults[0])) {
|
||||
$type = $defaults[0];
|
||||
unset($defaults[0]);
|
||||
}
|
||||
$extra = array_diff_key($defaults, compact(
|
||||
'conditions', 'fields', 'order', 'limit', 'page', 'recursive'
|
||||
));
|
||||
|
|
|
@ -604,6 +604,26 @@ class ControllerTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertEqual($Controller->params['paging']['ControllerPost']['options'],$expected);
|
||||
}
|
||||
/**
|
||||
* Test that special paginate types are called and that the type param doesn't leak out into defaults or options.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testPaginateSpecialType() {
|
||||
$Controller =& new Controller();
|
||||
$Controller->uses = array('ControllerPost', 'ControllerComment');
|
||||
$Controller->passedArgs[] = '1';
|
||||
$Controller->params['url'] = array();
|
||||
$Controller->constructClasses();
|
||||
|
||||
$Controller->paginate = array('ControllerPost' => array('popular', 'fields' => array('id', 'title')));
|
||||
$result = $Controller->paginate('ControllerPost');
|
||||
|
||||
$this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(2, 3));
|
||||
$this->assertEqual($Controller->ControllerPost->lastQuery['conditions'], array('ControllerPost.id > ' => '1'));
|
||||
$this->assertFalse(isset($Controller->params['paging']['ControllerPost']['defaults'][0]));
|
||||
$this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0]));
|
||||
}
|
||||
/**
|
||||
* testDefaultPaginateParams method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue