mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding lower bound for page numbers in Controller::paginate() (Ticket #3683)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6133 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
0b9f2c1b9d
commit
e56b92255f
2 changed files with 7 additions and 0 deletions
|
@ -952,6 +952,8 @@ class Controller extends Object {
|
|||
|
||||
if ($page == 'last' || $page >= $pageCount) {
|
||||
$options['page'] = $page = $pageCount;
|
||||
} elseif (intval($page) < 1) {
|
||||
$options['page'] = $page = 1;
|
||||
}
|
||||
|
||||
if (method_exists($object, 'paginate')) {
|
||||
|
|
|
@ -96,6 +96,11 @@ class ControllerTest extends CakeTestCase {
|
|||
$Controller->uses[0] = 'Plugin.ControllerPost';
|
||||
$results = Set::extract($Controller->paginate(), '{n}.ControllerPost.id');
|
||||
$this->assertEqual($results, array(1, 2, 3));
|
||||
|
||||
$Controller->passedArgs = array('page' => '-1');
|
||||
$results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id');
|
||||
$this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1);
|
||||
$this->assertEqual($results, array(1, 2, 3));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue