Backwards compatibility and formatting fix for #17897

This commit is contained in:
Alexander Makarov
2020-03-04 01:59:57 +03:00
parent 7a36c964a4
commit fbdf464510
2 changed files with 7 additions and 7 deletions

View File

@ -1190,7 +1190,7 @@ class Command extends Component
* @return array the cache key * @return array the cache key
* @since 2.0.16 * @since 2.0.16
*/ */
protected function getCacheKey($method, $fetchMode) protected function getCacheKey($method, $fetchMode, $rawSql)
{ {
$params = $this->params; $params = $this->params;
ksort($params); ksort($params);

View File

@ -391,18 +391,18 @@ class QueryBuilder extends \yii\db\QueryBuilder
*/ */
private function supportsFractionalSeconds() private function supportsFractionalSeconds()
{ {
// use cache to prevent open mysql connection // use cache to prevent opening MySQL connection
// https://github.com/yiisoft/yii2/issues/13749#issuecomment-481657224 // https://github.com/yiisoft/yii2/issues/13749#issuecomment-481657224
$key = [__METHOD__, $this->db->dsn]; $key = [__METHOD__, $this->db->dsn];
$cache = null; $cache = null;
$schemaCache = ( \Yii::$app && is_string($this->db->schemaCache) ) ? \Yii::$app->get($this->db->schemaCache, false) : $this->db->schemaCache; $schemaCache = (\Yii::$app && is_string($this->db->schemaCache) ? \Yii::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
if ( $this->db->enableSchemaCache && $schemaCache instanceof CacheInterface ) { if ($this->db->enableSchemaCache && $schemaCache instanceof CacheInterface) {
$cache = $schemaCache; $cache = $schemaCache;
} }
$version = $cache ? $cache->get($key) : null; $version = $cache ? $cache->get($key) : null;
if( !$version ) { if (!$version) {
$version = $this->db->getSlavePdo()->getAttribute(\PDO::ATTR_SERVER_VERSION); $version = $this->db->getSlavePdo()->getAttribute(\PDO::ATTR_SERVER_VERSION);
if( $cache ) { if ($cache) {
$cache->set($key, $version, $this->db->schemaCacheDuration); $cache->set($key, $version, $this->db->schemaCacheDuration);
} }
} }