From 7d2988f098a045c9e66d8845864449a035efc745 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 Content-Type: text/plain; charset=utf-8 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 --- Koha/Patrons/Import.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm index 2e11a2ebb7..b1c751007e 100644 --- a/Koha/Patrons/Import.pm +++ b/Koha/Patrons/Import.pm @@ -283,6 +283,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.30.2