mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Backwards compatibility and formatting fix for #17897
This commit is contained in:
@ -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);
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user