From 92dcb0375446a167f005f751551eab72b1402c37 Mon Sep 17 00:00:00 2001 From: lav45 Date: Fri, 17 Nov 2023 16:25:52 +0300 Subject: [PATCH] Fix ActiveDataProviderTest::testPaginationBeforeModels --- framework/data/BaseDataProvider.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/framework/data/BaseDataProvider.php b/framework/data/BaseDataProvider.php index 1ec7dda2e18..871f80515a3 100644 --- a/framework/data/BaseDataProvider.php +++ b/framework/data/BaseDataProvider.php @@ -210,16 +210,15 @@ public function getPagination() public function setPagination($value) { if (is_array($value)) { - $config = [ - 'class' => Pagination::className(), - 'totalCount' => $this->getTotalCount(), - ]; + $config = ['class' => Pagination::className()]; if ($this->id !== null) { $config['pageParam'] = $this->id . '-page'; $config['pageSizeParam'] = $this->id . '-per-page'; } - $this->_pagination = Yii::createObject(array_merge($config, $value)); - } elseif ($value instanceof Pagination || $value === false) { + $value = Yii::createObject(array_merge($config, $value)); + } + if ($value instanceof Pagination || $value === false) { + $value->totalCount = $this->getTotalCount(); $this->_pagination = $value; } else { throw new InvalidArgumentException('Only Pagination instance, configuration array or false is allowed.');