Commit 76402ea0 by jeicd

Fixed UrlManager rules caching

parent a97a35ba
...@@ -148,9 +148,9 @@ class UrlManager extends Component ...@@ -148,9 +148,9 @@ class UrlManager extends Component
$this->cache = Yii::$app->get($this->cache, false); $this->cache = Yii::$app->get($this->cache, false);
} }
if ($this->cache instanceof Cache) { if ($this->cache instanceof Cache) {
$key = __CLASS__; $cacheKey = __CLASS__;
$hash = md5(json_encode($this->rules)); $hash = md5(json_encode($this->rules));
if (($data = $this->cache->get($key)) !== false && isset($data[1]) && $data[1] === $hash) { if (($data = $this->cache->get($cacheKey)) !== false && isset($data[1]) && $data[1] === $hash) {
$this->rules = $data[0]; $this->rules = $data[0];
return; return;
...@@ -177,8 +177,8 @@ class UrlManager extends Component ...@@ -177,8 +177,8 @@ class UrlManager extends Component
} }
$this->rules = $rules; $this->rules = $rules;
if (isset($key, $hash)) { if (isset($cacheKey, $hash)) {
$this->cache->set($key, [$this->rules, $hash]); $this->cache->set($cacheKey, [$this->rules, $hash]);
} }
} }
......
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