Skip to content
Permalink
Browse files

Make maxLimit and limit settings independent.

Having maxLimit infer what it should be based on limit was not a very
transparent default behavior. The documentation states that maxLimit
will default to 100, but the code would default it to 'limit' if set.
This created confusing behavior when only one setting was defined.

Refs #5973
  • Loading branch information...
markstory committed Feb 28, 2015
1 parent 54edb1c commit 02c9dda9a7740c871ee33aa035953215e0da1e32
@@ -333,15 +333,13 @@ public function getDefaults($alias) {
if (isset($this->settings[$alias])) {
$defaults = $this->settings[$alias];
}
if (isset($defaults['limit']) &&
(empty($defaults['maxLimit']) || $defaults['limit'] > $defaults['maxLimit'])
) {
$defaults['maxLimit'] = $defaults['limit'];
}
return array_merge(
array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named'),
$defaults
$defaults += array(
'page' => 1,
'limit' => 20,
'maxLimit' => 100,
'paramType' => 'named'
);
return $defaults;
}
/**
@@ -853,7 +853,7 @@ public function testMergeOptionsMaxLimit() {
'paramType' => 'named',
);
$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->Paginator->settings = array(
@@ -872,7 +872,7 @@ public function testMergeOptionsMaxLimit() {
'paramType' => 'named',
);
$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);
}

0 comments on commit 02c9dda

Please sign in to comment.
You can’t perform that action at this time.