Skip to content

Commit

Permalink
Apply fixed review.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jul 10, 2024
1 parent 54702a8 commit 1171464
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 @@ -156,8 +156,6 @@ protected function prepareKeys($models)
return array_keys($models);
}

private $_totalCount = [];

/**
* {@inheritdoc}
*/
Expand All @@ -166,13 +164,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 1171464

Please sign in to comment.