diff --git a/docs/guide-zh-CN/runtime-logging.md b/docs/guide-zh-CN/runtime-logging.md index 025cef2642..126d002bff 100644 --- a/docs/guide-zh-CN/runtime-logging.md +++ b/docs/guide-zh-CN/runtime-logging.md @@ -300,7 +300,7 @@ return [ ]; ``` -> Note: 频繁的消息刷新和导出将降低你到应用性能。 +> Note: 频繁的消息刷新和导出将降低你的应用性能。 ### 切换日志目标 @@ -313,7 +313,7 @@ Yii::$app->log->targets['file']->enabled = false; ``` 上面的代码要求您将目标命名为 `file`,像下面展示的那样, -在 `targets` 数组中使用使用字符串键: +在 `targets` 数组中使用字符串键: ```php return [ @@ -386,6 +386,6 @@ return [ 假如你漏掉 `\Yii::endProfile('block1')` 或者切换了 `\Yii::endProfile('block1')` 和 `\Yii::endProfile('block2')` 的 顺序,那么性能分析将不会工作。 -对于每个被分析的代码块,一个带有严重程度 `profile` 的日志消息被记录。 +对于每个被分析的代码块,一个带有严重程度为 `profile` 的日志消息将被记录。 你可以配置一个 [log target](#log-targets) 去收集这些 消息,并且导出他们。[Yii debugger](tool-debugger.md) 有一个内建的性能分析面板能够展示分析结果。 diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index e348d9bc34..fa67dea0ff 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.16 under development ------------------------ +- Bug #16648: Html::strtolower() was corrupting UTF-8 strings (Kolyunya) - Bug #13977: Skip validation if file input does not exist (RobinKamps, s1lver) - Bug #16183: Fixed when `yii\helpers\BaseFileHelper` sometimes returned wrong value (samdark, SilverFire, OndrejVasicek) - Bug #13932: Fix number validator attributes comparison (uaoleg, s1lver) diff --git a/framework/helpers/BaseArrayHelper.php b/framework/helpers/BaseArrayHelper.php index e070db5599..a333910c40 100644 --- a/framework/helpers/BaseArrayHelper.php +++ b/framework/helpers/BaseArrayHelper.php @@ -143,7 +143,8 @@ class BaseArrayHelper /** * Retrieves the value of an array element or object property with the given key or property name. - * If the key does not exist in the array or object, the default value will be returned instead. + * If the key does not exist in the array, the default value will be returned instead. + * Not used when getting value from an object. * * The key may be specified in a dot format to retrieve the value of a sub-array or the property * of an embedded object. In particular, if the key is `x.y.z`, then the returned value would diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index 911bda6ff7..5b0440b291 100644 --- a/framework/helpers/BaseHtml.php +++ b/framework/helpers/BaseHtml.php @@ -2295,7 +2295,8 @@ class BaseHtml */ public static function getInputId($model, $attribute) { - $name = strtolower(static::getInputName($model, $attribute)); + $charset = Yii::$app ? Yii::$app->charset : 'UTF-8'; + $name = mb_strtolower(static::getInputName($model, $attribute), $charset); return str_replace(['[]', '][', '[', ']', ' ', '.'], ['', '-', '-', '', '-', '-'], $name); } diff --git a/framework/web/Controller.php b/framework/web/Controller.php index aca323eaa4..f3f538005e 100644 --- a/framework/web/Controller.php +++ b/framework/web/Controller.php @@ -200,6 +200,7 @@ class Controller extends \yii\base\Controller */ public function redirect($url, $statusCode = 302) { + // calling Url::to() here because Response::redirect() modifies route before calling Url::to() return Yii::$app->getResponse()->redirect(Url::to($url), $statusCode); } diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index 5f6c81227e..8e1846e10a 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/tests/framework/helpers/HtmlTest.php @@ -1778,6 +1778,19 @@ EOD; $this->assertSame($expected, $actual); } + /** + * @dataProvider testGetInputIdDataProvider + */ + public function testGetInputId($attributeName, $inputIdExpected) + { + $model = new DynamicModel(); + $model->defineAttribute($attributeName); + + $inputIdActual = Html::getInputId($model, $attributeName); + + $this->assertSame($inputIdExpected, $inputIdActual); + } + public function testEscapeJsRegularExpression() { $expected = '/[a-z0-9-]+/'; @@ -1858,6 +1871,45 @@ HTML; $this->assertContains('placeholder="My placeholder: Name"', $html); } + + public function testGetInputIdDataProvider() + { + return [ + [ + 'foo', + 'dynamicmodel-foo', + ], + [ + 'FooBar', + 'dynamicmodel-foobar', + ], + [ + 'Foo_Bar', + 'dynamicmodel-foo_bar', + ], + [ + 'foo[]', + 'dynamicmodel-foo', + ], + [ + 'foo[bar][baz]', + 'dynamicmodel-foo-bar-baz', + ], + + [ + 'foo.bar', + 'dynamicmodel-foo-bar', + ], + [ + 'bild_groß_dateiname', + 'dynamicmodel-bild_groß_dateiname', + ], + [ + 'ФуБарБаз', + 'dynamicmodel-фубарбаз', + ], + ]; + } } /** diff --git a/tests/framework/i18n/FormatterNumberTest.php b/tests/framework/i18n/FormatterNumberTest.php index 5b24f621cd..84bd715e04 100644 --- a/tests/framework/i18n/FormatterNumberTest.php +++ b/tests/framework/i18n/FormatterNumberTest.php @@ -109,6 +109,30 @@ class FormatterNumberTest extends TestCase $this->assertSame($this->formatter->nullDisplay, $this->formatter->asInteger(null)); } + /** + * @see https://github.com/yiisoft/yii2/issues/16900 + */ + public function testIntlAsIntegerOptions() + { + $this->formatter->numberFormatterTextOptions = [ + \NumberFormatter::POSITIVE_PREFIX => '+', + ]; + + $this->assertSame('+2', $this->formatter->asInteger(2)); + $this->assertSame('+10', $this->formatter->asInteger(10)); + $this->assertSame('+12', $this->formatter->asInteger(12)); + $this->assertSame('+123', $this->formatter->asInteger(123)); + $this->assertSame('+1,230', $this->formatter->asInteger(1230)); + $this->assertSame('+123', $this->formatter->asInteger(123.23)); + $this->assertSame('+123', $this->formatter->asInteger(123.53)); + $this->assertSame('+0', $this->formatter->asInteger(0)); + $this->assertSame('-123', $this->formatter->asInteger(-123.23)); + $this->assertSame('-123', $this->formatter->asInteger(-123.53)); + + $this->assertSame('+123,456', $this->formatter->asInteger(123456)); + $this->assertSame('+123,456', $this->formatter->asInteger(123456.789)); + } + /** * @expectedException \yii\base\InvalidParamException */