From 140570d1860a5734f9e47de75bf1197853a3380a Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 17 Jun 2024 13:20:35 +0300 Subject: [PATCH] Remove cache \yii\data\ActiveDataProvider::prepareTotalCount() (#20206) --- framework/data/ActiveDataProvider.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) 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); } /**