]> git.agnieray.net Git - galette.git/commitdiff
Fix parent loading
authorJohan Cwiklinski <johan@x-tnd.be>
Sun, 11 Jun 2023 16:39:45 +0000 (18:39 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 11 Jun 2023 16:39:45 +0000 (18:39 +0200)
galette/lib/Galette/Controllers/Crud/MembersController.php
galette/lib/Galette/Entity/Adherent.php

index ba6511edefd2a6ba391405f57372762c10a67b25..dee07fba797afbe3c1c147107dc9153c1bd0ca71 100644 (file)
@@ -270,7 +270,7 @@ class MembersController extends CrudController
         }
 
         if ($member->id == null) {
-            //member does not exists!
+            //member does not exist!
             $this->flash->addMessage(
                 'error_detected',
                 str_replace('%id', $id, _T("No member #%id."))
index 58c633ca2f868c1e2eaa63cdf8bbadec0936d327..a0296b67c9ad9e989b5610fdc81085e4544e55d1 100644 (file)
@@ -455,7 +455,7 @@ class Adherent
      */
     private function loadParent(): void
     {
-        if (!$this->_parent instanceof Adherent) {
+        if ($this->_parent !== null && !$this->_parent instanceof Adherent) {
             $deps = array_fill_keys(array_keys($this->_deps), false);
             $this->_parent = new Adherent($this->zdb, (int)$this->_parent, $deps);
         }
@@ -1923,7 +1923,7 @@ class Adherent
     public function getEmail(): string
     {
         $email = $this->_email;
-        if (empty($email)) {
+        if (empty($email) && $this->hasParent()) {
             $this->loadParent();
             $email = $this->parent->email;
         }