Browse Source

feat: fix codeclimate error

tags/2.0.33
Ather Shu 5 years ago
parent
commit
990c4be454
  1. 5
      framework/db/Command.php
  2. 8
      framework/db/mysql/QueryBuilder.php

5
framework/db/Command.php

@ -1140,7 +1140,7 @@ class Command extends Component
if (is_array($info)) {
/* @var $cache \yii\caching\CacheInterface */
$cache = $info[0];
$cacheKey = $this->getCacheKey($method, $fetchMode, $rawSql);
$cacheKey = $this->getCacheKey($method, $fetchMode);
$result = $cache->get($cacheKey);
if (is_array($result) && isset($result[0])) {
Yii::debug('Query result served from cache', 'yii\db\Command::query');
@ -1187,11 +1187,10 @@ class Command extends Component
* @param string $method method of PDOStatement to be called
* @param int $fetchMode the result fetch mode. Please refer to [PHP manual](https://secure.php.net/manual/en/function.PDOStatement-setFetchMode.php)
* for valid fetch modes.
* @param string $rawSql Deprecated since 2.0.33, the raw SQL with parameter values inserted into the corresponding placeholders
* @return array the cache key
* @since 2.0.16
*/
protected function getCacheKey($method, $fetchMode, $rawSql)
protected function getCacheKey($method, $fetchMode)
{
$params = $this->params;
ksort($params);

8
framework/db/mysql/QueryBuilder.php

@ -395,11 +395,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
// https://github.com/yiisoft/yii2/issues/13749#issuecomment-481657224
$key = [__METHOD__, $this->db->dsn];
$cache = null;
if ( $this->db->enableSchemaCache ) {
$schemaCache = is_string($this->db->schemaCache) ? \Yii::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
if ($schemaCache instanceof CacheInterface) {
$cache = $schemaCache;
}
$schemaCache = is_string($this->db->schemaCache) ? \Yii::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
if ( $this->db->enableSchemaCache && $schemaCache instanceof CacheInterface ) {
$cache = $schemaCache;
}
$version = $cache ? $cache->get($key) : null;
if( !$version ) {

Loading…
Cancel
Save