Fixed infinite loop when an element gets assigned itself as parent

This fixes issue #230
This commit is contained in:
Jan Böhmer 2023-03-02 22:55:22 +01:00
parent d1b8a36b93
commit 7394a23a83
5 changed files with 32 additions and 4 deletions

View file

@ -282,6 +282,12 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
*/
public function getSubelements(): iterable
{
//If the parent is equal to this object, we would get an endless loop, so just return an empty array
//This is just a workaround, as validator should prevent this behaviour, before it gets written to the database
if ($this->parent === $this) {
return new ArrayCollection();
}
return $this->children ?? new ArrayCollection();
}