diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index d6ee3222d3..9c6ac66d06 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -11,6 +11,7 @@ Yii Framework 2 Change Log - Bug #7037: `yii\console\controllers\AssetController` now correctly handles relative image URLs if source and target CSS are under same directory (klimov-paul) - Bug #7055: composite IN condition was not generated correctly for certain DBMS (nineinchnick) - Bug #7074: `yii\data\ArrayDataProvider` did not correctly handle the case `Pagination::pageSize = 0` (kirsenn, qiangxue) +- Bug #7211: Query caching should properly deal with the case when query result is false (qiangxue) - Bug #7218: `yii\captcha\CaptchaAction` should send response in JSON format (InteLigent, qiangxue) - Bug #7226: `yii\web\Request::getEtag()` should strip off `-gzip` which may be added by Apache (mcd-php) - Bug #7227: Query builder should respect column alias setting when `yii\db\Expression` is being selected (mdmunir, qiangxue) diff --git a/framework/db/Command.php b/framework/db/Command.php index 4398417d9a..d88d13f3c8 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -805,9 +805,10 @@ class Command extends Component $this->db->username, $rawSql, ]; - if (($result = $cache->get($cacheKey)) !== false) { + $result = $cache->get($cacheKey); + if (is_array($result) && isset($result[0])) { Yii::trace('Query result served from cache', 'yii\db\Command::query'); - return $result; + return $result[0]; } } } @@ -837,7 +838,7 @@ class Command extends Component } if (isset($cache, $cacheKey, $info)) { - $cache->set($cacheKey, $result, $info[1], $info[2]); + $cache->set($cacheKey, [$result], $info[1], $info[2]); Yii::trace('Saved query result in cache', 'yii\db\Command::query'); }