Skip to content

Commit

Permalink
Ensure we don't break when removing (mulitple) Relations out of order
Browse files Browse the repository at this point in the history
  • Loading branch information
bobdenotter committed Sep 25, 2023
1 parent 8a00997 commit 2ee6927
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Controller/Backend/ContentEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/ContentExtrasTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
trait ContentExtrasTrait
{
/** @var ContentExtension */
/** @var ContentExtension|null */
private $contentExtension;

public function setContentExtension(ContentExtension $contentExtension): void
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function setPosition(int $position): self
return $this;
}

public function getFromContent(): Content
public function getFromContent(): ?Content
{
return $this->fromContent;
}
Expand All @@ -116,7 +116,7 @@ public function setFromContent($content): void
$this->fromContent = $content;
}

public function getToContent(): Content
public function getToContent(): ?Content
{
return $this->toContent;
}
Expand Down

0 comments on commit 2ee6927

Please sign in to comment.