Merge branch 'master' into doc

This commit is contained in:
崔亮
2018-11-22 17:03:49 +08:00
committed by GitHub
7 changed files with 85 additions and 5 deletions

View File

@ -300,7 +300,7 @@ return [
];
```
> Note: 频繁的消息刷新和导出将降低你应用性能。
> Note: 频繁的消息刷新和导出将降低你应用性能。
### 切换日志目标 <span id="toggling-log-targets"></span>
@ -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) 有一个内建的性能分析面板能够展示分析结果。

View File

@ -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)

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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-фубарбаз',
],
];
}
}
/**

View File

@ -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
*/