mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 22:32:40 +08:00
Fixes #9253: Allow variations to be a string for yii\filters\PageCache and yii\widgets\FragmentCache
This commit is contained in:
committed by
Alexander Makarov
parent
b0aa7a73de
commit
c8fbe40352
@ -22,6 +22,7 @@ Yii Framework 2 Change Log
|
||||
- Enh #5515: Added default value for `yii\behaviors\BlameableBehavior` for cases when the user is guest (dmirogin)
|
||||
- Enh #8752: Allow specify `$attributeNames` as a string for `yii\base\Model` `validate()` method (developeruz)
|
||||
- Enh #9137: Added `Access-Control-Allow-Method` header for the OPTIONS request (developeruz)
|
||||
- Enh #9253: Allow `variations` to be a string for `yii\filters\PageCache` and `yii\widgets\FragmentCache` (schojniak, developeruz)
|
||||
- Enh #14043: Added `yii\helpers\IpHelper` (silverfire, cebe)
|
||||
- Enh #7996: Short syntax for verb in GroupUrlRule (schojniak, developeruz)
|
||||
- Enh #14568: Refactored migration templates to use `safeUp()` and `safeDown()` methods (Kolyunya)
|
||||
|
||||
@ -88,7 +88,7 @@ class PageCache extends ActionFilter
|
||||
*/
|
||||
public $dependency;
|
||||
/**
|
||||
* @var array list of factors that would cause the variation of the content being cached.
|
||||
* @var string[]|string list of factors that would cause the variation of the content being cached.
|
||||
* Each factor is a string representing a variation (e.g. the language, a GET parameter).
|
||||
* The following variation setting will cause the content to be cached in different versions
|
||||
* according to the current application language:
|
||||
@ -323,12 +323,6 @@ class PageCache extends ActionFilter
|
||||
if ($this->varyByRoute) {
|
||||
$key[] = Yii::$app->requestedRoute;
|
||||
}
|
||||
if (is_array($this->variations)) {
|
||||
foreach ($this->variations as $value) {
|
||||
$key[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $key;
|
||||
return array_merge($key, (array)$this->variations);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class FragmentCache extends Widget
|
||||
*/
|
||||
public $dependency;
|
||||
/**
|
||||
* @var array list of factors that would cause the variation of the content being cached.
|
||||
* @var string[]|string list of factors that would cause the variation of the content being cached.
|
||||
* Each factor is a string representing a variation (e.g. the language, a GET parameter).
|
||||
* The following variation setting will cause the content to be cached in different versions
|
||||
* according to the current application language:
|
||||
@ -189,13 +189,6 @@ class FragmentCache extends Widget
|
||||
*/
|
||||
protected function calculateKey()
|
||||
{
|
||||
$factors = [__CLASS__, $this->getId()];
|
||||
if (is_array($this->variations)) {
|
||||
foreach ($this->variations as $factor) {
|
||||
$factors[] = $factor;
|
||||
}
|
||||
}
|
||||
|
||||
return $factors;
|
||||
return array_merge([__CLASS__, $this->getId()], (array)$this->variations);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user