mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Fix #19693: Fix db/Command not caching NULL
result with scalar fetchMode
This commit is contained in:
@ -4,12 +4,12 @@ Yii Framework 2 Change Log
|
||||
2.0.48 under development
|
||||
------------------------
|
||||
|
||||
- Bug #19693: Fix db/Command not caching `NULL` result with scalar fetchMode (Arkeins)
|
||||
- Enh #15376: Added cache usage for `yii2\rbac\DbManager::getRolesByUser()` (manchenkoff)
|
||||
- Enh #9740: Usage of DI instead of new keyword in Schemas (manchenkoff)
|
||||
- Enh #19689: Remove empty elements from the `class` array in `yii\helpers\BaseHtml::renderTagAttributes()` to prevent unwanted spaces (MoritzLost)
|
||||
- Chg #19696: Change visibility of `yii\web\View::isPageEnded` to `protected` (lubosdz, samdark)
|
||||
|
||||
|
||||
2.0.47 November 18, 2022
|
||||
------------------------
|
||||
|
||||
|
@ -1153,7 +1153,7 @@ class Command extends Component
|
||||
$cache = $info[0];
|
||||
$cacheKey = $this->getCacheKey($method, $fetchMode, '');
|
||||
$result = $cache->get($cacheKey);
|
||||
if (is_array($result) && isset($result[0])) {
|
||||
if (is_array($result) && array_key_exists(0, $result)) {
|
||||
Yii::debug('Query result served from cache', 'yii\db\Command::query');
|
||||
return $result[0];
|
||||
}
|
||||
|
@ -727,6 +727,11 @@ abstract class QueryTest extends DatabaseTestCase
|
||||
$this->assertEquals('user1', $query->noCache()->where(['id' => 1])->scalar($db));
|
||||
$this->assertEquals('user11', $query->cache()->where(['id' => 1])->scalar($db));
|
||||
}, 10);
|
||||
|
||||
$update->bindValues([':id' => 3, ':name' => null])->execute();
|
||||
$this->assertEquals(null, $query->cache()->where(['id' => 3])->scalar($db));
|
||||
$update->bindValues([':id' => 3, ':name' => 'user3'])->execute();
|
||||
$this->assertEquals(null, $query->cache()->where(['id' => 3])->scalar($db), 'Null value should be cached.');
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user