From ddbdd6ed50b77fb1953db67f12012bd1437dc025 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Thu, 30 Jan 2025 16:02:27 -0800 Subject: [PATCH] Fixed #16598 --- CHANGELOG.md | 1 + src/base/NestedElementTrait.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b59b4163cd..3d4f3049555 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fixed a bug where element card attributes weren’t saving for field layouts that didn’t have any tabs. ([#16589](https://github.com/craftcms/cms/issues/16589)) - Fixed an error that occurred when attempting to move entries to a new section, if they didn’t exist in the primary site. ([#16421](https://github.com/craftcms/cms/issues/16421)) - Fixed a bug where Link fields weren’t responsive for newly-created nested entries. ([#16592](https://github.com/craftcms/cms/issues/16592)) +- Fixed an error that could occur when executing the `utils/prune-orphaned-entries` command. ([#16598](https://github.com/craftcms/cms/issues/16598)) ## 5.6.3 - 2024-01-29 diff --git a/src/base/NestedElementTrait.php b/src/base/NestedElementTrait.php index 3d102c36177..3049d1269ad 100644 --- a/src/base/NestedElementTrait.php +++ b/src/base/NestedElementTrait.php @@ -378,7 +378,11 @@ protected function ownerType(): ?string if (!$ownerId) { return null; } - $this->ownerType = Craft::$app->getElements()->getElementTypeById($ownerId); + $ownerType = Craft::$app->getElements()->getElementTypeById($ownerId); + if (!$ownerType) { + return null; + } + $this->ownerType = $ownerType; } return $this->ownerType; }