diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index f0bdfce..b6374b5 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -65,6 +65,7 @@ Yii Framework 2 Change Log - Enh #14363: Added `yii\widgets\LinkPager::$linkContainerOptions` and possibility to override tag in `yii\widgets\LinkPager::$options` (dmirogin) - Bug #14202: Fixed current time in (UTC) `\Yii::$app->formatter` if time not set (bscheshirwork) - Bug #11825: User can login by cookie only once when `autoRenewCookie` is set to false (shirase, silverfire) +- Bug #13969: Fixed a bug in a `yii\console\controllers\CacheController` when caches defined via a closure were not detected (Kolyunya) 2.0.12 June 05, 2017 diff --git a/framework/console/controllers/CacheController.php b/framework/console/controllers/CacheController.php index ef53cd4..2a43ce6 100644 --- a/framework/console/controllers/CacheController.php +++ b/framework/console/controllers/CacheController.php @@ -271,6 +271,12 @@ class CacheController extends Controller $caches[$name] = $component['class']; } elseif (is_string($component) && $this->isCacheClass($component)) { $caches[$name] = $component; + } elseif ($component instanceof \Closure) { + $cache = Yii::$app->get($name); + if ($this->isCacheClass($cache)) { + $cacheClass = get_class($cache); + $caches[$name] = $cacheClass; + } } } diff --git a/tests/framework/console/controllers/CacheControllerTest.php b/tests/framework/console/controllers/CacheControllerTest.php index 8949681..0ee763f 100644 --- a/tests/framework/console/controllers/CacheControllerTest.php +++ b/tests/framework/console/controllers/CacheControllerTest.php @@ -8,6 +8,7 @@ namespace yiiunit\framework\console\controllers; use Yii; +use yii\caching\ArrayCache; use yii\console\controllers\CacheController; use yiiunit\TestCase; @@ -49,7 +50,9 @@ class CacheControllerTest extends TestCase $this->mockApplication([ 'components' => [ 'firstCache' => 'yii\caching\ArrayCache', - 'secondCache' => 'yii\caching\ArrayCache', + 'secondCache' => function () { + return new ArrayCache(); + }, 'session' => 'yii\web\CacheSession', // should be ignored at `actionFlushAll()` 'db' => [ 'class' => isset($config['class']) ? $config['class'] : 'yii\db\Connection',