From 67470afd0589502eccf63164b0ed4481a29a8ca1 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sun, 17 Mar 2024 18:55:20 +0100 Subject: [PATCH] Cannot set member as its own parent; closes #1806 --- galette/lib/Galette/Entity/Adherent.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/galette/lib/Galette/Entity/Adherent.php b/galette/lib/Galette/Entity/Adherent.php index e6d67b4d9..f8de8e0f0 100644 --- a/galette/lib/Galette/Entity/Adherent.php +++ b/galette/lib/Galette/Entity/Adherent.php @@ -1457,8 +1457,14 @@ class Adherent } break; case 'parent_id': - $this->$prop = ($value instanceof Adherent) ? (int)$value->id : (int)$value; - $this->loadParent(); + $pid = ($value instanceof Adherent) ? (int)$value->id : (int)$value; + if ($pid === $this->id) { + $this->errors[] = _T("A member cannot be its own parent!"); + $this->$prop = null; + } else { + $this->$prop = $pid; + $this->loadParent(); + } break; } } -- 2.39.2