From 2d15c484ef8dce38c5ddf5a62962bcaa56f8f490 Mon Sep 17 00:00:00 2001 From: tsvetiligo <31981639+tsvetiligo@users.noreply.github.com> Date: Sat, 2 May 2020 12:03:01 +0300 Subject: [PATCH] Fix #17961: Fix pagination `pageSizeLimit` ignore if set as array with more then 2 elements --- framework/CHANGELOG.md | 1 + framework/data/Pagination.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index bf8a8abf99..023622e0e6 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 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) - 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) diff --git a/framework/data/Pagination.php b/framework/data/Pagination.php index c8c12d0349..5006d9ea0b 100644 --- a/framework/data/Pagination.php +++ b/framework/data/Pagination.php @@ -213,7 +213,7 @@ class Pagination extends BaseObject implements Linkable public function getPageSize() { if ($this->_pageSize === null) { - if (empty($this->pageSizeLimit)) { + if (empty($this->pageSizeLimit) || !isset($this->pageSizeLimit[0], $this->pageSizeLimit[1])) { $pageSize = $this->defaultPageSize; $this->setPageSize($pageSize); } else { @@ -235,7 +235,7 @@ class Pagination extends BaseObject implements Linkable $this->_pageSize = null; } else { $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]) { $value = $this->pageSizeLimit[0]; } elseif ($value > $this->pageSizeLimit[1]) {