From 1116217b9382ea5efd001c5f8fb6eb57531b8ef4 Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Mon, 18 Nov 2024 13:11:36 +0000 Subject: [PATCH] don't freak out if the owner is new for site (still provisional draft) --- src/base/NestedElementTrait.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/base/NestedElementTrait.php b/src/base/NestedElementTrait.php index f0a7856ca48..e6907b577fd 100644 --- a/src/base/NestedElementTrait.php +++ b/src/base/NestedElementTrait.php @@ -154,8 +154,9 @@ public function getPrimaryOwner(): ?ElementInterface return null; } - $this->_primaryOwner = Craft::$app->getElements()->getElementById($primaryOwnerId, null, $this->siteId, [ + $this->_primaryOwner = Craft::$app->getElements()->getElementById($primaryOwnerId, null, null, [ 'trashed' => null, + 'preferSites' => [$this->siteId], ]) ?? false; if (!$this->_primaryOwner) { throw new InvalidConfigException("Invalid owner ID: $primaryOwnerId");