Skip to content

Commit

Permalink
Fix #972
Browse files Browse the repository at this point in the history
  • Loading branch information
ttempleton committed Dec 18, 2024
1 parent 5e46945 commit 806b68a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

### Fixed
- Fixed an 'Undefined array key' error that occurred during Neo-to-Matrix conversion, if any of the Neo field's block types had fields with overridden handles

## 5.2.20 - 2024-12-13

### Changed
Expand Down
6 changes: 3 additions & 3 deletions src/services/Conversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ public function convertFieldToMatrix(Field $neoField, bool $deleteOldBlockTypesA
$neoBlockTypeId = $neoBlockTypeIds[$matrixEntryType->uid];
$neoToMatrixTypeIds[$neoBlockTypeId] = $matrixEntryType->id;

// Create mapping from newly saved block type field handles to their IDs.
// Create mapping from newly saved block type's field UUIDs to their IDs.
// This is so that relations can be updated later on with the new field ID.
$matrixFields = $matrixEntryType->getFieldLayout()->getCustomFields();
$fieldIds = [];

foreach ($matrixFields as $matrixFieldLayoutField) {
$fieldIds[$matrixFieldLayoutField->handle] = $matrixFieldLayoutField->id;
$fieldIds[$matrixFieldLayoutField->uid] = $matrixFieldLayoutField->id;
}

$matrixEntryTypeFieldIds[$matrixEntryType->id] = $fieldIds;
Expand Down Expand Up @@ -171,7 +171,7 @@ public function convertFieldToMatrix(Field $neoField, bool $deleteOldBlockTypesA
$globalFieldId = $relation['fieldId'];
$globalField = $globalFields[$globalFieldId];
$matrixFieldIds = $matrixEntryTypeFieldIds[$matrixEntryTypeId];
$matrixFieldId = $matrixFieldIds[$globalField->handle];
$matrixFieldId = $matrixFieldIds[$globalField->uid];
$newRelations[] = [
$matrixFieldId,
$matrixEntryId,
Expand Down

0 comments on commit 806b68a

Please sign in to comment.