Commit 684365e8 by Klimov Paul Committed by Carsten Brandt

Fixed `yii\console\controllers\CacheController` does not check if cache…

Fixed `yii\console\controllers\CacheController` does not check if cache component instance of 'yii\caching\Cache' close #5055
parent 8c5d175a
......@@ -98,6 +98,7 @@ Yii Framework 2 Change Log
- Bug #5001: `yii\rest\CreateAction`, `yii\rest\UpdateAction` and `yii\rest\DeleteAction` should throw 500 error if the model operation returns false without validation errors (qiangxue)
- Bug #5039: `UniqueValidator` and `ExistValidator` did not respect query conditions added by default scope (qiangxue)
- Bug #5049: `ActiveForm::validationDelay` should be applied to user types only (qiangxue)
- Bug #5055: Fixed `yii\console\controllers\CacheController` does not check if cache component instance of 'yii\caching\Cache' (klimov-paul)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul)
- Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
......
......@@ -212,9 +212,9 @@ class CacheController extends Controller
if ($component instanceof Cache) {
$caches[$name] = get_class($component);
} elseif (is_array($component) && isset($component['class']) && strpos($component['class'], 'Cache') !== false) {
} elseif (is_array($component) && isset($component['class']) && $this->isCacheClass($component['class'])) {
$caches[$name] = $component['class'];
} elseif (is_string($component) && strpos($component, 'Cache') !== false) {
} elseif (is_string($component) && $this->isCacheClass($component)) {
$caches[$name] = $component;
}
}
......@@ -222,4 +222,14 @@ class CacheController extends Controller
return $caches;
}
/**
* Checks if given class is a Cache class.
* @param string $className class name.
* @return boolean
*/
private function isCacheClass($className)
{
return is_subclass_of($className, Cache::className());
}
}
......@@ -33,6 +33,7 @@ class CacheControllerTest extends TestCase
'components' => [
'firstCache' => 'yii\caching\ArrayCache',
'secondCache' => 'yii\caching\ArrayCache',
'session' => 'yii\web\CacheSession', // should be ignored at `actionFlushAll()`
],
]);
}
......
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