From c82aedb86db6b4ea250c063d633f543fb65ca134 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 14 Nov 2018 15:56:03 +0100 Subject: [PATCH 1/7] add a comment to explain why Url::to() is called in Controller::redirect() close #16887 --- framework/web/Controller.php | 1 + 1 file changed, 1 insertion(+) 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); } From 13bded0935d20a7d13de173f94c8ca03ee6b8910 Mon Sep 17 00:00:00 2001 From: sockball Date: Thu, 15 Nov 2018 03:05:38 +0800 Subject: [PATCH 2/7] Update runtime-logging.md (#16886) [skip ci] --- docs/guide-zh-CN/runtime-logging.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guide-zh-CN/runtime-logging.md b/docs/guide-zh-CN/runtime-logging.md index abe69b1a02..a5aeb6fcd6 100644 --- a/docs/guide-zh-CN/runtime-logging.md +++ b/docs/guide-zh-CN/runtime-logging.md @@ -299,7 +299,7 @@ return [ ]; ``` -> Note: 频繁的消息刷新和导出将降低你到应用性能。 +> Note: 频繁的消息刷新和导出将降低你的应用性能。 ### 切换日志目标 @@ -312,7 +312,7 @@ Yii::$app->log->targets['file']->enabled = false; ``` 上面的代码要求您将目标命名为 `file`,像下面展示的那样, -在 `targets` 数组中使用使用字符串键: +在 `targets` 数组中使用字符串键: ```php return [ @@ -379,6 +379,6 @@ return [ 假如你漏掉 `\Yii::endProfile('block1')` 或者切换了 `\Yii::endProfile('block1')` 和 `\Yii::endProfile('block2')` 的 顺序,那么性能分析将不会工作。 -对于每个被分析的代码块,一个带有严重程度 `profile` 的日志消息被记录。 +对于每个被分析的代码块,一个带有严重程度为 `profile` 的日志消息将被记录。 你可以配置一个 [log target](#log-targets) 去收集这些 消息,并且导出他们。[Yii debugger](tool-debugger.md) 有一个内建的性能分析面板能够展示分析结果。 From 383953d9b78e517fd5a0ef107d8400094a2e7b46 Mon Sep 17 00:00:00 2001 From: Viktor Kabachenko Date: Sun, 18 Nov 2018 11:16:52 +0300 Subject: [PATCH 3/7] Update BaseArrayHelper.php (#1) (#16894) --- framework/helpers/BaseArrayHelper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 06227c7075c1312974baf9062d87d502f003ae32 Mon Sep 17 00:00:00 2001 From: Nikolay Oleynikov Date: Tue, 20 Nov 2018 01:09:03 +0300 Subject: [PATCH 4/7] Fixes #16648: Html::strtolower() was corrupting UTF-8 strings --- framework/CHANGELOG.md | 1 + framework/helpers/BaseHtml.php | 3 +- tests/framework/helpers/HtmlTest.php | 52 ++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) 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/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/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-фубарбаз', + ], + ]; + } } /** From 8334ab3060dc97fac87c1fb176ce6d92be175e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jankowiak?= Date: Mon, 19 Nov 2018 23:12:17 +0100 Subject: [PATCH 5/7] Fixes #16629: ActiveField::inputOptions were not merged with options passed for radio and checkbox --- framework/CHANGELOG.md | 1 + framework/widgets/ActiveField.php | 4 ++ tests/framework/widgets/ActiveFieldTest.php | 79 ++++++++++++++++++++- 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index fa67dea0ff..defcfeedf4 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.16 under development ------------------------ +- Bug #16629: ActiveField::inputOptions were not merged with options passed for radio and checkbox (paweljankowiak06) - 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) diff --git a/framework/widgets/ActiveField.php b/framework/widgets/ActiveField.php index cf23b8c007..40ee34e778 100644 --- a/framework/widgets/ActiveField.php +++ b/framework/widgets/ActiveField.php @@ -542,6 +542,8 @@ class ActiveField extends Component */ public function radio($options = [], $enclosedByLabel = true) { + $options = array_merge($this->inputOptions, $options); + if ($enclosedByLabel) { $this->parts['{input}'] = Html::activeRadio($this->model, $this->attribute, $options); $this->parts['{label}'] = ''; @@ -594,6 +596,8 @@ class ActiveField extends Component */ public function checkbox($options = [], $enclosedByLabel = true) { + $options = array_merge($this->inputOptions, $options); + if ($enclosedByLabel) { $this->parts['{input}'] = Html::activeCheckbox($this->model, $this->attribute, $options); $this->parts['{label}'] = ''; diff --git a/tests/framework/widgets/ActiveFieldTest.php b/tests/framework/widgets/ActiveFieldTest.php index 9b3d32b5ec..8b675dc878 100644 --- a/tests/framework/widgets/ActiveFieldTest.php +++ b/tests/framework/widgets/ActiveFieldTest.php @@ -249,7 +249,7 @@ EOT; public function testTabularInputErrors() { - $this->activeField->attribute = '[0]'.$this->attributeName; + $this->activeField->attribute = '[0]' . $this->attributeName; $this->helperModel->addError($this->attributeName, 'Error Message'); $expectedValue = '
'; @@ -584,6 +584,78 @@ HTML; $this->assertEqualsWithoutLE($expectedValue, trim($actualValue)); } + public function testInputOptionsAreMergedFromActiveField() + { + $this->removeLabelHintAndError(); + $expectedValue = ''; + $field = $this->activeField->input('text', ['data-id' => 3])->render(); + self::assertContains($expectedValue, $field); + } + + public function testTextInputOptionsAreMergedFromActiveField() + { + $this->removeLabelHintAndError(); + $expectedValue = ''; + $field = $this->activeField->textInput(['data-id' => 3])->render(); + self::assertContains($expectedValue, $field); + } + + public function testHiddenInputOptionsAreMergedFromActiveField() + { + $this->removeLabelHintAndError(); + $expectedValue = ''; + $field = $this->activeField->hiddenInput(['data-id' => 3])->render(); + self::assertContains($expectedValue, $field); + } + + public function testPasswordInputOptionsAreMergedFromActiveField() + { + $this->removeLabelHintAndError(); + $expectedValue = ''; + $field = $this->activeField->passwordInput(['data-id' => 3])->render(); + self::assertContains($expectedValue, $field); + } + + public function testTextareaInputOptionsAreMergedFromActiveField() + { + $this->removeLabelHintAndError(); + $expectedValue = '