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(); } /**