Merge pull request #5981 from cakephp/issue-5973

Make maxLimit and limit settings independent.
This commit is contained in:
José Lorenzo Rodríguez 2015-03-01 19:48:26 +01:00
commit a6ceec149a
2 changed files with 8 additions and 10 deletions

View file

@ -333,15 +333,13 @@ class PaginatorComponent extends Component {
if (isset($this->settings[$alias])) { if (isset($this->settings[$alias])) {
$defaults = $this->settings[$alias]; $defaults = $this->settings[$alias];
} }
if (isset($defaults['limit']) && $defaults += array(
(empty($defaults['maxLimit']) || $defaults['limit'] > $defaults['maxLimit']) 'page' => 1,
) { 'limit' => 20,
$defaults['maxLimit'] = $defaults['limit']; 'maxLimit' => 100,
} 'paramType' => 'named'
return array_merge(
array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named'),
$defaults
); );
return $defaults;
} }
/** /**

View file

@ -853,7 +853,7 @@ class PaginatorComponentTest extends CakeTestCase {
'paramType' => 'named', 'paramType' => 'named',
); );
$result = $this->Paginator->mergeOptions('Post'); $result = $this->Paginator->mergeOptions('Post');
$expected = array('page' => 1, 'limit' => 200, 'maxLimit' => 200, 'paramType' => 'named'); $expected = array('page' => 1, 'limit' => 200, 'maxLimit' => 100, 'paramType' => 'named');
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$this->Paginator->settings = array( $this->Paginator->settings = array(
@ -872,7 +872,7 @@ class PaginatorComponentTest extends CakeTestCase {
'paramType' => 'named', 'paramType' => 'named',
); );
$result = $this->Paginator->mergeOptions('Post'); $result = $this->Paginator->mergeOptions('Post');
$expected = array('page' => 1, 'limit' => 500, 'maxLimit' => 150, 'paramType' => 'named'); $expected = array('page' => 1, 'limit' => 500, 'maxLimit' => 100, 'paramType' => 'named');
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }