diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e00908c..376d0a59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Feed Me +## Unreleased + +- Fixed a PHP error that could occur when importing into some 3rd party fields. ([#1264](https://github.com/craftcms/feed-me/issues/1264), [#1265](https://github.com/craftcms/feed-me/pull/1265)) + ## 5.1.1 - 2023-03-20 - Fixed a JavaScript error that would occur on case-sensitive filesystems when using Feed Me. ([#1260](https://github.com/craftcms/feed-me/pull/1260), [#1257](https://github.com/craftcms/feed-me/issues/1257), [#1258](https://github.com/craftcms/feed-me/issues/1258), [#1259](https://github.com/craftcms/feed-me/issues/1259)) diff --git a/src/helpers/DataHelper.php b/src/helpers/DataHelper.php index ec688c0b..3c689884 100644 --- a/src/helpers/DataHelper.php +++ b/src/helpers/DataHelper.php @@ -116,10 +116,10 @@ public static function fetchDefaultArrayValue($fieldInfo) /** * @param $feedData * @param $fieldInfo - * @param array|FeedModel $feed + * @param array|FeedModel|null $feed * @return array|ArrayAccess|mixed|null */ - public static function fetchValue($feedData, $fieldInfo, $feed): mixed + public static function fetchValue($feedData, $fieldInfo, $feed = null): mixed { // $feed will be a FeedModel when calling `fetchValue` from an element if ($feed instanceof FeedModel) { @@ -174,7 +174,7 @@ public static function fetchValue($feedData, $fieldInfo, $feed): mixed } // If setEmptyValues is enabled allow overwriting existing data - if ($value === "" && $feed['setEmptyValues']) { + if ($feed !== null && $value === "" && $feed['setEmptyValues']) { return $value; }