From d70738975517acd90d1d4e15d0ce131ccfd5f41c Mon Sep 17 00:00:00 2001 From: Max Roeleveld Date: Mon, 9 Oct 2023 10:49:53 +0200 Subject: [PATCH 1/2] Explicitly remove a removed Relation from the newRelations collection. This fixes a bug where removing a relation between two Content entities would result in an error. Fixes #3486 --- src/Controller/Backend/ContentEditController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Controller/Backend/ContentEditController.php b/src/Controller/Backend/ContentEditController.php index 960db2a6b..ac5e4b355 100644 --- a/src/Controller/Backend/ContentEditController.php +++ b/src/Controller/Backend/ContentEditController.php @@ -606,6 +606,7 @@ static function (Relation $relation) use ($content) { ) { $currentRelation->getFromContent()->removeRelationsFromThisContent($currentRelation); } + $currentRelations = $currentRelations->filter(fn(Relation $r) => $r !== $currentRelation); $this->em->remove($currentRelation); } From 3a5b6588eba669c8e1f40e6d044c37db91bca82f Mon Sep 17 00:00:00 2001 From: Max Roeleveld Date: Mon, 9 Oct 2023 11:02:20 +0200 Subject: [PATCH 2/2] Make the fix PHP7.x compatible. --- src/Controller/Backend/ContentEditController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Controller/Backend/ContentEditController.php b/src/Controller/Backend/ContentEditController.php index 5041d41f4..a960dd472 100644 --- a/src/Controller/Backend/ContentEditController.php +++ b/src/Controller/Backend/ContentEditController.php @@ -630,7 +630,11 @@ static function (Relation $relation) use ($content) { ) { $currentRelation->getFromContent()->removeRelationsFromThisContent($currentRelation); } - $currentRelations = $currentRelations->filter(fn(Relation $r) => $r !== $currentRelation); + $currentRelations = $currentRelations->filter( + static function (Relation $r) use ($currentRelation) { + return $r !== $currentRelation; + } + ); $this->em->remove($currentRelation); }