]> git.agnieray.net Git - galette.git/commitdiff
Cannot set member as its own parent; closes #1806
authorJohan Cwiklinski <johan@x-tnd.be>
Sun, 17 Mar 2024 17:55:20 +0000 (18:55 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 17 Mar 2024 17:55:39 +0000 (18:55 +0100)
galette/lib/Galette/Entity/Adherent.php

index 8234f6c7de0f74eedf15721c270f9648a1754192..5b0a5968be62b6b4bae9c2cbcf4797d8972cfbdd 100644 (file)
@@ -1478,8 +1478,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;
         }
     }