From 3f086f8cf232f83cd8d53afb9af38ed028d7d784 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 10 Apr 2024 14:11:53 +0200 Subject: [PATCH] Few fixes on import --- galette/lib/Galette/Entity/Adherent.php | 2 +- galette/lib/Galette/Util/Password.php | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/galette/lib/Galette/Entity/Adherent.php b/galette/lib/Galette/Entity/Adherent.php index 074ed0340..ee75684a9 100644 --- a/galette/lib/Galette/Entity/Adherent.php +++ b/galette/lib/Galette/Entity/Adherent.php @@ -1830,7 +1830,7 @@ class Adherent case 'sname': return $this->getNameWithCase($this->name, $this->surname); case 'rbirthdate': - return $this->birthdate; + return $this->birthdate ?? null; case 'sgender': switch ($this->gender) { case self::MAN: diff --git a/galette/lib/Galette/Util/Password.php b/galette/lib/Galette/Util/Password.php index e12e0b738..16718c56c 100644 --- a/galette/lib/Galette/Util/Password.php +++ b/galette/lib/Galette/Util/Password.php @@ -252,14 +252,16 @@ class Password ]; //handle date formats - $bdate = \DateTime::createFromFormat('Y-m-d', $adh->rbirthdate); - if ($bdate !== false) { - $infos[] = $bdate->format('Y-m-d'); //standard format - //TRANS: see https://www.php.net/manual/datetime.format.php - $infos[] = $bdate->format(__('Y-m-d')); //localized format - $infos[] = $bdate->format('Ymd'); - $infos[] = $bdate->format('dmY'); - $infos[] = $bdate->format('Ydm'); + if ($adh->rbirthdate !== null) { + $bdate = \DateTime::createFromFormat('Y-m-d', $adh->rbirthdate); + if ($bdate !== false) { + $infos[] = $bdate->format('Y-m-d'); //standard format + //TRANS: see https://www.php.net/manual/datetime.format.php + $infos[] = $bdate->format(__('Y-m-d')); //localized format + $infos[] = $bdate->format('Ymd'); + $infos[] = $bdate->format('dmY'); + $infos[] = $bdate->format('Ydm'); + } } //some possible combinations -- 2.39.2