Browse Source

Fix console cache controller

Fixed a bug in a `yii\console\controllers\CacheController` when caches
defined via a closure were not detected.

fixes #13969
close #14586
tags/2.0.13
Kolyunya 7 years ago committed by Carsten Brandt
parent
commit
f866edcfba
No known key found for this signature in database
GPG Key ID: BE4F41DE1DEEEED0
  1. 1
      framework/CHANGELOG.md
  2. 6
      framework/console/controllers/CacheController.php
  3. 5
      tests/framework/console/controllers/CacheControllerTest.php

1
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

6
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;
}
}
}

5
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',

Loading…
Cancel
Save