Skip to content

Commit

Permalink
Fixed a missing check when getting blocktypes by context if the matri…
Browse files Browse the repository at this point in the history
…x field doesn’t exist yet.

Fixes #92
  • Loading branch information
joshangell committed Jul 30, 2020
1 parent 8fb55ee commit 06637c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed
- Fixed an issue with newer versions of Super Table ([#98](https://github.com/angell-co/Spoon/issues/98))
- Fixed an error that could occur when matrix fields don’t return properly by ID ([#92](https://github.com/angell-co/Spoon/issues/92))


## 3.5.2 - 2020-02-07
Expand Down
6 changes: 4 additions & 2 deletions src/services/BlockTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ public function getByContext($context, $groupBy = null, $ignoreSubContext = fals

foreach ($blockTypeRecords as $blockTypeRecord) {
$blockType = $this->_populateBlockTypeFromRecord($blockTypeRecord);
$this->_blockTypesByContext[$context][$blockType->id] = $blockType;
if ($blockType) {
$this->_blockTypesByContext[$context][$blockType->id] = $blockType;
}
}

} else {
Expand Down Expand Up @@ -466,7 +468,7 @@ private function _populateBlockTypeFromRecord(BlockTypeRecord $blockTypeRecord)
'groupSortOrder',
'sortOrder'
]));

// Use the fieldId to get the field and save the handle on to the model
/** @var Field $matrixField */
$matrixField = Craft::$app->fields->getFieldById($blockType->fieldId);
Expand Down

0 comments on commit 06637c8

Please sign in to comment.