From cf7139c5ee0c7055a6cf525297900760a0f24223 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 6 Jun 2024 00:37:24 +0300 Subject: [PATCH] Apply suggestions from code review --- framework/data/ActiveDataProvider.php | 2 +- framework/data/Pagination.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/data/ActiveDataProvider.php b/framework/data/ActiveDataProvider.php index a46a8a30851..357b1eb74ef 100644 --- a/framework/data/ActiveDataProvider.php +++ b/framework/data/ActiveDataProvider.php @@ -164,7 +164,7 @@ protected function prepareTotalCount() $query = (clone $this->query)->limit(-1)->offset(-1)->orderBy([]); $key = md5((string)$query); - if (isset($this->_totalCount[$key]) === false) { + if (!array_key_exists($key, $this->_totalCount)) { $this->_totalCount[$key] = (int)$query->count('*', $this->db); } return $this->_totalCount[$key]; diff --git a/framework/data/Pagination.php b/framework/data/Pagination.php index 08c12a351cc..372c35000e5 100644 --- a/framework/data/Pagination.php +++ b/framework/data/Pagination.php @@ -142,7 +142,7 @@ class Pagination extends BaseObject implements Linkable */ private $_pageSize; /** - * @var Closure|int return total number of items. + * @var Closure|int total number of items or closure returning it. */ private $_totalCount = 0; @@ -353,7 +353,7 @@ public function getTotalCount() if (is_numeric($this->_totalCount)) { return (int)$this->_totalCount; } - return (int)call_user_func($this->_totalCount); + return (int)$this->_totalCount(); } /**