Skip to content

Commit

Permalink
Merge branch 'release/4.2.0.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jul 27, 2022
2 parents 7465e19 + 2054f3d commit be5dc3a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Release Notes for Craft CMS 4

## 4.2.0.1 - 2022-07-26

### Fixed
- Fixed an error that could occur when passing an object into `craft\helpers\ArrayHelper::removeValue()` or the `|without` filter.

## 4.2.0 - 2022-07-26

### Added
- The control panel is now translated into Ukranian.
- The control panel is now translated into Ukrainian.
- Element conditions can now include condition rules for Matrix fields. ([#11620](https://github.com/craftcms/cms/issues/11620))
- Element conditions can now include condition rules for Money fields. ([#11560](https://github.com/craftcms/cms/issues/11560))
- Added the “Notification Duration” user accessibility preference. ([#11612](https://github.com/craftcms/cms/pull/11612))
Expand Down
2 changes: 1 addition & 1 deletion src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [
'id' => 'CraftCMS',
'name' => 'Craft CMS',
'version' => '4.2.0',
'version' => '4.2.0.1',
'schemaVersion' => '4.0.0.9',
'minVersionRequired' => '3.7.11',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
8 changes: 6 additions & 2 deletions src/helpers/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,17 @@ public static function getValue($array, $key, $default = null)
*/
public static function removeValue(&$array, $value, bool $strict = false)
{
if (is_object($value)) {
$strict = true;
}

$result = [];

if (is_array($array)) {
foreach ($array as $key => $val) {
if (
($strict && $val === $value) ||
(!$strict && $val == $value)
(($strict || is_object($val)) && $val === $value) ||
(!$strict && !is_object($val) && $val == $value)
) {
$result[$key] = $val;
unset($array[$key]);
Expand Down
20 changes: 10 additions & 10 deletions src/translations/fa/app.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/unit/helpers/ArrayHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,9 @@ public function getValueDataProvider(): array

public function removeValueDataProvider(): array
{
$obj1 = (object)['foo' => true];
$obj2 = (object)['bar' => true];

return [
[
['a', 'b'],
Expand All @@ -672,6 +675,11 @@ public function removeValueDataProvider(): array
3,
true,
],
[
[$obj1, $obj2],
[$obj1, $obj2],
1,
],
];
}
}

0 comments on commit be5dc3a

Please sign in to comment.