Fix #17961: Fix pagination pageSizeLimit ignore if set as array with more then 2 elements

This commit is contained in:
tsvetiligo
2020-05-02 12:03:01 +03:00
committed by GitHub
parent 088fd518fe
commit 2d15c484ef
2 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.35 under development 2.0.35 under development
------------------------ ------------------------
- Bug #17961: Fix pagination `pageSizeLimit` ignore if set as array with more then 2 elements (tsvetiligo)
- Bug #18011: Added attribute labels support for `DynamicModel`, fixed `EachValidator` to pass the attribute label to the underlying `DynamicModel` (storch) - Bug #18011: Added attribute labels support for `DynamicModel`, fixed `EachValidator` to pass the attribute label to the underlying `DynamicModel` (storch)
- Enh #18019: Allow jQuery 3.5.0 to be installed (wouter90) - Enh #18019: Allow jQuery 3.5.0 to be installed (wouter90)
- Bug #17653: Fix `TypeError: pair[1] is undefined` when query param doesn't have = sign (baso10) - Bug #17653: Fix `TypeError: pair[1] is undefined` when query param doesn't have = sign (baso10)

View File

@ -213,7 +213,7 @@ class Pagination extends BaseObject implements Linkable
public function getPageSize() public function getPageSize()
{ {
if ($this->_pageSize === null) { if ($this->_pageSize === null) {
if (empty($this->pageSizeLimit)) { if (empty($this->pageSizeLimit) || !isset($this->pageSizeLimit[0], $this->pageSizeLimit[1])) {
$pageSize = $this->defaultPageSize; $pageSize = $this->defaultPageSize;
$this->setPageSize($pageSize); $this->setPageSize($pageSize);
} else { } else {
@ -235,7 +235,7 @@ class Pagination extends BaseObject implements Linkable
$this->_pageSize = null; $this->_pageSize = null;
} else { } else {
$value = (int) $value; $value = (int) $value;
if ($validatePageSize && isset($this->pageSizeLimit[0], $this->pageSizeLimit[1]) && count($this->pageSizeLimit) === 2) { if ($validatePageSize && isset($this->pageSizeLimit[0], $this->pageSizeLimit[1])) {
if ($value < $this->pageSizeLimit[0]) { if ($value < $this->pageSizeLimit[0]) {
$value = $this->pageSizeLimit[0]; $value = $this->pageSizeLimit[0];
} elseif ($value > $this->pageSizeLimit[1]) { } elseif ($value > $this->pageSizeLimit[1]) {