mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Fixed infinite loop when an element gets assigned itself as parent
This fixes issue #230
This commit is contained in:
parent
d1b8a36b93
commit
7394a23a83
5 changed files with 32 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue