Skip to content

Commit

Permalink
Fixed #16339
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 17, 2024
1 parent 1b0bf2f commit 952361d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fixed a bug where field conditions weren’t taking effect within Matrix fields set to inline-editable blocks mode, if the owner element didn’t support drafts. ([#16315](https://github.com/craftcms/cms/pull/16315))
- Fixed a bug where Matrix fields’ entry types weren’t maintaining their original block type order when upgrading to Craft 5. ([#16314](https://github.com/craftcms/cms/issues/16314))
- Fixed a bug where element card labels were getting cut off when wrapped. ([#16325](https://github.com/craftcms/cms/issues/16325))
- Fixed a PHP error that could occur when eager-loading `owner` or `primaryOwner` on nested elements. ([#16339](https://github.com/craftcms/cms/issues/16339))

## 5.5.6.1 - 2024-12-11

Expand Down
7 changes: 6 additions & 1 deletion src/base/NestedElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ public static function eagerLoadingMap(array $sourceElements, string $handle): a
case 'owner':
case 'primaryOwner':
/** @var NestedElementInterface[] $sourceElements */
$ownerId = $sourceElements[0]->getOwnerId();
if (!$ownerId) {
return false;
}

return [
'elementType' => get_class(reset($sourceElements)),
'elementType' => Craft::$app->getElements()->getElementTypeById($ownerId),
'map' => array_map(fn(NestedElementInterface $element) => [
'source' => $element->id,
'target' => match ($handle) {
Expand Down

0 comments on commit 952361d

Please sign in to comment.