Skip to content

Commit

Permalink
https://github.com/craftcms/feed-me/pull/1237
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybrad committed Mar 16, 2023
1 parent 871cd79 commit 9c272ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Fixed a compatibility issue with v4.3+ of the Google Maps plugin. If patching an existing feed, it may be necessary to remap the Address subfields. ([#1245](https://github.com/craftcms/feed-me/pull/1245))
- Fixed multiple issues that could occur when importing elements mapped to a structure section. ([#1240](https://github.com/craftcms/feed-me/pull/1240), [#1154](https://github.com/craftcms/feed-me/issues/1154))
- Fixed a PHP error that could occur when importing into a relational field inside of Matrix under certain circumstances. ([#1069](https://github.com/craftcms/feed-me/issues/1069))
- Fixed a bug where simple array comparisons might return false if the values were identical, but the keys were mixed. ([#1237](https://github.com/craftcms/feed-me/pull/1237/), [#1238](https://github.com/craftcms/feed-me/issues/1238))
- Fixed an PHP error that would occur if you tried to import a new Asset with a filename > 255 characters.

## 5.0.5 - 2023-01-09
Expand Down
13 changes: 13 additions & 0 deletions src/helpers/DataHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,19 @@ public static function arrayCompare($array1, $array2): bool|array
*/
private static function _compareSimpleValues($fields, $key, $firstValue, $secondValue): bool
{
// When the values are arrays filled with numbers then they most likely represent references to elements.
// Unfortunately these arrays sometimes have non-matching keys, while the values are the same, i.e. reference
// the same elements. In this case, we should determine that the values are the same.
if (Hash::check($fields, $key)
&& is_array($firstValue)
&& is_array($secondValue)
&& array_reduce($firstValue, static fn($carry, $item) => $carry && is_numeric($item), true)
&& array_reduce($secondValue, static fn($carry, $item) => $carry && is_numeric($item), true)
&& array_values($firstValue) == array_values($secondValue)
) {
return true;
}

// When the values are empty arrays we do NOT use the Hash::check below because that will always return false
if (is_array($firstValue) && is_array($secondValue) && count($firstValue) === 0 && count($secondValue) === 0) {
return true;
Expand Down

0 comments on commit 9c272ab

Please sign in to comment.