Commit ec3aadff by Qiang Xue

Fixes #2862: Using `DbCache` while enabling schema caching may cause infinite loops

parent f3c26d3c
......@@ -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)
......
......@@ -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];
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment