mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fixes #16192: yii\db\Command::logQuery() is now protected, extracted getCacheKey() from queryInternal()
This commit is contained in:
committed by
Alexander Makarov
parent
b32ba1132e
commit
32c7c4161b
@ -37,7 +37,7 @@ Yii Framework 2 Change Log
|
|||||||
- Bug #16292: Fixed misconfigured CORS filter exception throwing. Now it throws `InvalidConfigException` in Debug mode (khvalov)
|
- Bug #16292: Fixed misconfigured CORS filter exception throwing. Now it throws `InvalidConfigException` in Debug mode (khvalov)
|
||||||
- Bug #16301: Fixed `yii\web\User::setIdentity()` to clear access check cache while setting identity object to `null` (Izumi-kun)
|
- Bug #16301: Fixed `yii\web\User::setIdentity()` to clear access check cache while setting identity object to `null` (Izumi-kun)
|
||||||
- Bug #16322: Fixed strings were not were not compared using timing attack resistant approach while CSRF token validation (samdark, Felix Wiedemann)
|
- Bug #16322: Fixed strings were not were not compared using timing attack resistant approach while CSRF token validation (samdark, Felix Wiedemann)
|
||||||
- Chg #16192: `yii\db\Command::logQuery()` is now protected (drlibra)
|
- Chg #16192: `yii\db\Command::logQuery()` is now protected, extracted `getCacheKey()` from `queryInternal()` (drlibra)
|
||||||
- Bug #16377: Fixed `yii\base\Event:off()` undefined index error when event handler does not match (razvanphp)
|
- Bug #16377: Fixed `yii\base\Event:off()` undefined index error when event handler does not match (razvanphp)
|
||||||
|
|
||||||
2.0.15.1 March 21, 2018
|
2.0.15.1 March 21, 2018
|
||||||
|
|||||||
@ -1140,14 +1140,8 @@ class Command extends Component
|
|||||||
if (is_array($info)) {
|
if (is_array($info)) {
|
||||||
/* @var $cache \yii\caching\CacheInterface */
|
/* @var $cache \yii\caching\CacheInterface */
|
||||||
$cache = $info[0];
|
$cache = $info[0];
|
||||||
$cacheKey = [
|
$rawSql = $rawSql ?: $this->getRawSql();
|
||||||
__CLASS__,
|
$cacheKey = $this->getCacheKey($method, $fetchMode, $rawSql);
|
||||||
$method,
|
|
||||||
$fetchMode,
|
|
||||||
$this->db->dsn,
|
|
||||||
$this->db->username,
|
|
||||||
$rawSql ?: $rawSql = $this->getRawSql(),
|
|
||||||
];
|
|
||||||
$result = $cache->get($cacheKey);
|
$result = $cache->get($cacheKey);
|
||||||
if (is_array($result) && isset($result[0])) {
|
if (is_array($result) && isset($result[0])) {
|
||||||
Yii::debug('Query result served from cache', 'yii\db\Command::query');
|
Yii::debug('Query result served from cache', 'yii\db\Command::query');
|
||||||
@ -1187,6 +1181,28 @@ class Command extends Component
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the cache key for the query.
|
||||||
|
*
|
||||||
|
* @param string $method method of PDOStatement to be called
|
||||||
|
* @param int $fetchMode the result fetch mode. Please refer to [PHP manual](http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php)
|
||||||
|
* for valid fetch modes.
|
||||||
|
* @param string $rawSql 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)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
__CLASS__,
|
||||||
|
$method,
|
||||||
|
$fetchMode,
|
||||||
|
$this->db->dsn,
|
||||||
|
$this->db->username,
|
||||||
|
$rawSql,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a specified table schema to be refreshed after command execution.
|
* Marks a specified table schema to be refreshed after command execution.
|
||||||
* @param string $name name of the table, which schema should be refreshed.
|
* @param string $name name of the table, which schema should be refreshed.
|
||||||
|
|||||||
Reference in New Issue
Block a user