diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index eb42d3e..1fd1f8e 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -62,6 +62,7 @@ Yii Framework 2 Change Log - Bug #2760: Fixed GridView `filterUrl` parameters (qiangxue, AlexGx) - Bug #2834: When overriding i18n translation sources from config using `app*` or `yii*` default `app` and `yii` sources were not removed (samdark) - Bug #2848: Individual queries should be enclosed within parenthesis in a UNION query (qiangxue) +- Bug #2862: Using `DbCache` while enabling schema caching may cause infinite loops (qiangxue) - Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark) - Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark) - Bug: Json::encode() did not handle objects that implement JsonSerializable interface correctly (cebe) diff --git a/framework/db/Schema.php b/framework/db/Schema.php index 7cdb46c..fdfcf2d 100644 --- a/framework/db/Schema.php +++ b/framework/db/Schema.php @@ -87,7 +87,7 @@ abstract class Schema extends Object */ public function getTableSchema($name, $refresh = false) { - if (isset($this->_tables[$name]) && !$refresh) { + if (array_key_exists($name, $this->_tables) && !$refresh) { return $this->_tables[$name]; } @@ -100,15 +100,17 @@ abstract class Schema extends Object if ($cache instanceof Cache) { $key = $this->getCacheKey($name); if ($refresh || ($table = $cache->get($key)) === false) { - $table = $this->loadTableSchema($realName); + $this->_tables[$name] = $table = $this->loadTableSchema($realName); if ($table !== null) { $cache->set($key, $table, $db->schemaCacheDuration, new GroupDependency([ 'group' => $this->getCacheGroup(), ])); } + } else { + $this->_tables[$name] = $table; } - return $this->_tables[$name] = $table; + return $this->_tables[$name]; } }