Skip to content

Commit

Permalink
Remove cache \yii\data\ActiveDataProvider::prepareTotalCount() (#20206)
Browse files Browse the repository at this point in the history
  • Loading branch information
lav45 authored Jun 17, 2024
1 parent fe5688d commit 140570d
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions framework/data/ActiveDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ protected function prepareKeys($models)
return array_keys($models);
}

private $_totalCount = [];

/**
* {@inheritdoc}
*/
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 140570d

Please sign in to comment.