Browse Source

Fixes #15301: Fixed `ArrayHelper::filter()` to work properly with `0` in values

tags/2.0.14
hhniao 7 years ago committed by Alexander Makarov
parent
commit
d2423cd6ca
  1. 1
      framework/CHANGELOG.md
  2. 2
      framework/helpers/BaseArrayHelper.php
  3. 10
      tests/framework/helpers/ArrayHelperTest.php

1
framework/CHANGELOG.md

@ -21,6 +21,7 @@ Yii Framework 2 Change Log
- 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)
- 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
framework/helpers/BaseArrayHelper.php

@ -938,7 +938,7 @@ class BaseArrayHelper
continue;
}
if (empty($array[$globalKey])) {
if (!key_exists($globalKey, $array)) {
continue;
}
if ($localKey === null) {

10
tests/framework/helpers/ArrayHelperTest.php

@ -1269,5 +1269,15 @@ class ArrayHelperTest extends TestCase
$this->assertEquals(ArrayHelper::filter($array, ['X']), []);
$this->assertEquals(ArrayHelper::filter($array, ['X.Y']), []);
$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);
}
}

Loading…
Cancel
Save