mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 06:11:35 +08:00
Fixes #15301: Fixed ArrayHelper::filter()
to work properly with 0
in values
This commit is contained in:

committed by
Alexander Makarov

parent
b20d2692a1
commit
d2423cd6ca
@ -21,6 +21,7 @@ Yii Framework 2 Change Log
|
|||||||
- Enh #15221: Added support for the `--<option> <value>` console option syntax (brandonkelly)
|
- Enh #15221: Added support for the `--<option> <value>` console option syntax (brandonkelly)
|
||||||
- Enh #15221: Improved the `help/list-action-options` console command output for command options without a description (brandonkelly)
|
- Enh #15221: Improved the `help/list-action-options` console command output for command options without a description (brandonkelly)
|
||||||
- Bug #15270: Resolved potential race conditions when writing generated php-files (kalessil)
|
- Bug #15270: Resolved potential race conditions when writing generated php-files (kalessil)
|
||||||
|
- Bug #15301: Fixed `ArrayHelper::filter()` to work properly with `0` in values (hhniao)
|
||||||
|
|
||||||
2.0.13.1 November 14, 2017
|
2.0.13.1 November 14, 2017
|
||||||
--------------------------
|
--------------------------
|
||||||
|
@ -938,7 +938,7 @@ class BaseArrayHelper
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($array[$globalKey])) {
|
if (!key_exists($globalKey, $array)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($localKey === null) {
|
if ($localKey === null) {
|
||||||
|
@ -1269,5 +1269,15 @@ class ArrayHelperTest extends TestCase
|
|||||||
$this->assertEquals(ArrayHelper::filter($array, ['X']), []);
|
$this->assertEquals(ArrayHelper::filter($array, ['X']), []);
|
||||||
$this->assertEquals(ArrayHelper::filter($array, ['X.Y']), []);
|
$this->assertEquals(ArrayHelper::filter($array, ['X.Y']), []);
|
||||||
$this->assertEquals(ArrayHelper::filter($array, ['A.X']), []);
|
$this->assertEquals(ArrayHelper::filter($array, ['A.X']), []);
|
||||||
|
|
||||||
|
$tmp = [
|
||||||
|
'a' => 0,
|
||||||
|
'b' => '',
|
||||||
|
'c' => false,
|
||||||
|
'd' => null,
|
||||||
|
'e' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->assertEquals(ArrayHelper::filter($tmp, array_keys($tmp)), $tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user