diff --git a/framework/data/ActiveDataProvider.php b/framework/data/ActiveDataProvider.php index 357b1eb74ef..1a098cd6474 100644 --- a/framework/data/ActiveDataProvider.php +++ b/framework/data/ActiveDataProvider.php @@ -151,8 +151,6 @@ protected function prepareKeys($models) return array_keys($models); } - private $_totalCount = []; - /** * {@inheritdoc} */ @@ -161,13 +159,8 @@ protected function prepareTotalCount() if (!$this->query instanceof QueryInterface) { throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.'); } - $query = (clone $this->query)->limit(-1)->offset(-1)->orderBy([]); - $key = md5((string)$query); - - if (!array_key_exists($key, $this->_totalCount)) { - $this->_totalCount[$key] = (int)$query->count('*', $this->db); - } - return $this->_totalCount[$key]; + $query = clone $this->query; + return (int) $query->limit(-1)->offset(-1)->orderBy([])->count('*', $this->db); } /**