octicon-rss(16/)
You've already forked yii2
mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-10 02:13:17 +08:00
Fix caching in Formatter::getUnitMessage() (#19445)
* Fix caching in `Formatter::getUnitMessage()` * Update FormatterTest.php * Update CHANGELOG.md
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
committed by
GitHub
gitea-unlock(16/)
parent
f72310c398
commit
474a67da99
octicon-diff(16/tw-mr-1) 3 changed files with 7 additions and 5 deletions
@@ -35,6 +35,7 @@ Yii Framework 2 Change Log
|
|||||||
- Enh #19416: Update and improve configurations for `yii\console\controllers\MessageController` (WinterSilence)
|
- Enh #19416: Update and improve configurations for `yii\console\controllers\MessageController` (WinterSilence)
|
||||||
- Bug #19403: Fix types in `yii\web\SessionIterator` (WinterSilence)
|
- Bug #19403: Fix types in `yii\web\SessionIterator` (WinterSilence)
|
||||||
- Enh #19420: Update list of JS callbacks in `yii\widgets\MaskedInput` (WinterSilence)
|
- Enh #19420: Update list of JS callbacks in `yii\widgets\MaskedInput` (WinterSilence)
|
||||||
|
- Bug #19445: Fix caching in `yii\i18n\Formatter::getUnitMessage()` (WinterSilence)
|
||||||
|
|
||||||
|
|
||||||
2.0.45 February 11, 2022
|
2.0.45 February 11, 2022
|
||||||
|
|||||||
@@ -1643,8 +1643,8 @@ class Formatter extends Component
|
|||||||
*/
|
*/
|
||||||
private function getUnitMessage($unitType, $unitFormat, $system, $position)
|
private function getUnitMessage($unitType, $unitFormat, $system, $position)
|
||||||
{
|
{
|
||||||
if (isset($this->_unitMessages[$unitType][$system][$position])) {
|
if (isset($this->_unitMessages[$unitType][$unitFormat][$system][$position])) {
|
||||||
return $this->_unitMessages[$unitType][$system][$position];
|
return $this->_unitMessages[$unitType][$unitFormat][$system][$position];
|
||||||
}
|
}
|
||||||
if (!$this->_intlLoaded) {
|
if (!$this->_intlLoaded) {
|
||||||
throw new InvalidConfigException('Format of ' . $unitType . ' is only supported when PHP intl extension is installed.');
|
throw new InvalidConfigException('Format of ' . $unitType . ' is only supported when PHP intl extension is installed.');
|
||||||
@@ -1676,7 +1676,7 @@ class Formatter extends Component
|
|||||||
$message[] = "$key{{$value}}";
|
$message[] = "$key{{$value}}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_unitMessages[$unitType][$system][$position] = '{n, plural, ' . implode(' ', $message) . '}';
|
return $this->_unitMessages[$unitType][$unitFormat][$system][$position] = '{n, plural, ' . implode(' ', $message) . '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,14 +34,15 @@ class FormatterTest extends TestCase
|
|||||||
'timeZone' => 'UTC',
|
'timeZone' => 'UTC',
|
||||||
'language' => 'ru-RU',
|
'language' => 'ru-RU',
|
||||||
]);
|
]);
|
||||||
$this->formatter = new Formatter(['locale' => 'en-US']);
|
if (!isset($this->formatter)) {
|
||||||
|
$this->formatter = new Formatter(['locale' => 'en-US']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
IntlTestHelper::resetIntlStatus();
|
IntlTestHelper::resetIntlStatus();
|
||||||
$this->formatter = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormat()
|
public function testFormat()
|
||||||
|
|||||||
Reference in New Issue
Block a user