From 868dda4b0702e2355130fdd40424b90a178153c4 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 25 Sep 2023 10:34:18 +0000 Subject: [PATCH] Bug 34883: Stop patron expiry date being set to NULL during import A regression has been identified whereby an empty field in the dateexpiry field in a patron import file will cause the patron's expiry date to be set to NULL. This patch addresses this by checking for an empty field and using the existing expiry date if one is found. Test plan: 1) Setup a csv with column headers: surname firstname branchcode categorycode cardnumber dateenrolled dateexpiry 2) Add values: Acosta Edna CPL PT 23529001000463 02/01/2013 3) Leave the dateexpiry column blank 4) Check Edna and make a note of her patron expiry date 5) Run the import_patrons.pl script with the following flags: a) --file b) --matchpoint cardnumber c) --confirm d) --overwrite 6) Check Edna, note her expiry date is now set to NULL 7) Manually edit Edna's expiry date to be reset to what it was before you ran the script 8) Apply the patch and restart_all 9) Repeat step 5 10) Check Edna, this time her expiry date should be the same as the value you set it to in step 7 11) Sign off! Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit f4f77357f63013a21e700f14df82ca9261403310) Signed-off-by: Fridolin Somers (cherry picked from commit 08002cd0b94987164e93650e07ecb32fdfdf8822) Signed-off-by: Matt Blenkinsop --- Koha/Patrons/Import.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm index 73d5355149..45f968e9e8 100644 --- a/Koha/Patrons/Import.pm +++ b/Koha/Patrons/Import.pm @@ -282,6 +282,8 @@ sub import_patrons { next if $col eq 'password' && !$overwrite_passwords; next if $col eq 'dateexpiry' && $update_dateexpiry; + $borrower{$col} = $member->{$col} if $col eq 'dateexpiry' && !$columns[ $csvkeycol{$col} ]; + unless ( exists( $csvkeycol{$col} ) || $defaults->{$col} ) { $borrower{$col} = $member->{$col} if ( $member->{$col} ); } -- 2.39.5