diff --git a/CHANGELOG.md b/CHANGELOG.md index 59aefb27..fcd3ced3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Feed Me +## Unreleased + +- Fixed a bug where importing into an entry type with hidden title attribute would cause an error. ([#1423](https://github.com/craftcms/feed-me/pull/1423)) + ## 6.0.0 - 2024-03-19 - Feed Me now requires Craft CMS 5.0.0-beta.2 or later. diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index 49693206..4db9ed02 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -126,13 +126,15 @@ public function parseField(): mixed $fieldData[$key] = $parsedValue; } } - foreach ($fields['attributes'] as $fieldHandle => $fieldInfo) { - $node = Hash::get($fieldInfo, 'node'); - if ($node === 'usedefault') { - $key = $this->_getBlockKey($nodePathSegments, $blockHandle, $fieldHandle); - - $parsedValue = DataHelper::fetchSimpleValue($this->feedData, $fieldInfo); - $attributeData[$key] = $parsedValue; + if ($attributeInfo) { + foreach ($fields['attributes'] as $fieldHandle => $fieldInfo) { + $node = Hash::get($fieldInfo, 'node'); + if ($node === 'usedefault') { + $key = $this->_getBlockKey($nodePathSegments, $blockHandle, $fieldHandle); + + $parsedValue = DataHelper::fetchSimpleValue($this->feedData, $fieldInfo); + $attributeData[$key] = $parsedValue; + } } } } @@ -257,7 +259,7 @@ private function _getBlockKey(array $nodePathSegments, string $blockHandle, stri private function _getFieldMappingInfoForNodePath($nodePath, $blocks): ?array { foreach ($blocks as $blockHandle => $blockInfo) { - $fields = Hash::get($blockInfo, 'fields'); + $fields = Hash::get($blockInfo, 'fields', []); $feedPath = preg_replace('/(\/\d+\/)/', '/', $nodePath); $feedPath = preg_replace('/^(\d+\/)|(\/\d+)/', '', $feedPath); @@ -304,7 +306,7 @@ private function _getFieldMappingInfoForNodePath($nodePath, $blocks): ?array private function _getAttributeMappingInfoForNodePath($nodePath, $blocks): ?array { foreach ($blocks as $blockHandle => $blockInfo) { - $fields = Hash::get($blockInfo, 'attributes'); + $fields = Hash::get($blockInfo, 'attributes', []); $feedPath = preg_replace('/(\/\d+\/)/', '/', $nodePath); $feedPath = preg_replace('/^(\d+\/)|(\/\d+)/', '', $feedPath);