From 2ee6927a5fb72791ff303d4ac8948c21a70f044e Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Mon, 25 Sep 2023 16:36:05 +0200 Subject: [PATCH] Ensure we don't break when removing (mulitple) Relations out of order --- src/Controller/Backend/ContentEditController.php | 4 +++- src/Entity/ContentExtrasTrait.php | 2 +- src/Entity/Relation.php | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Controller/Backend/ContentEditController.php b/src/Controller/Backend/ContentEditController.php index f5e45e2bd..7af9ad21c 100644 --- a/src/Controller/Backend/ContentEditController.php +++ b/src/Controller/Backend/ContentEditController.php @@ -629,9 +629,11 @@ static function (Relation $relation) use ($content) { $currentRelations ->first( static function (Relation $relation) use ($id) { + $fromId = $relation->getFromContent() ? $relation->getFromContent()->getId() : null; + $toId = $relation->getToContent() ? $relation->getToContent()->getId() : null; return \in_array( $id, - [$relation->getFromContent()->getId(), $relation->getToContent()->getId()], + [$fromId, $toId], true ); } diff --git a/src/Entity/ContentExtrasTrait.php b/src/Entity/ContentExtrasTrait.php index 3cba1f3bc..b61cd0736 100644 --- a/src/Entity/ContentExtrasTrait.php +++ b/src/Entity/ContentExtrasTrait.php @@ -12,7 +12,7 @@ */ trait ContentExtrasTrait { - /** @var ContentExtension */ + /** @var ContentExtension|null */ private $contentExtension; public function setContentExtension(ContentExtension $contentExtension): void diff --git a/src/Entity/Relation.php b/src/Entity/Relation.php index ec7b3fe22..f29bcdee9 100644 --- a/src/Entity/Relation.php +++ b/src/Entity/Relation.php @@ -106,7 +106,7 @@ public function setPosition(int $position): self return $this; } - public function getFromContent(): Content + public function getFromContent(): ?Content { return $this->fromContent; } @@ -116,7 +116,7 @@ public function setFromContent($content): void $this->fromContent = $content; } - public function getToContent(): Content + public function getToContent(): ?Content { return $this->toContent; }