From 9fa2db5362cbf7076697929b74ff26acdc240dc3 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Tue, 11 Nov 2025 04:33:05 +0000 Subject: [PATCH] Bug 41145: Do not delete the existing extended_attribute values when importing patrons Since bug 26744 was upstreamed when you use the Import patron tool or the import_patrons.pl script from the commandline and pass a preserve-extended-attributes parameter the borrowerlogs inaccurately have an entry added where the attribute 'before' value is empty. Test plan: 1. Create a patron attribute type named 'INSTID': Koha administration > Patrons and circulation > Patron attribute types > New patron attribute type. 2. Download the patron started CSV from: Tools > Import patrons > click the 'Download a Starter CSV file with all the columns.' link 3. Save values in the: cardnumber, surname, firstname, branchcode, categorycode, auth_method, lang, and patron_attributes columns 4. Make sure your value in the patron_attributes column is INSTID:1234 5. Import this csv file: cd misc ./import_patrons.pl --file .csv --matchpoint cardnumber --default branchcode=CPL --overwrite --preserve-extended-attributes --verbose --verbose --confirm 6. Navigate to the patron account in your browser 7. Click 'Modification log' and observe how many entries there are 8. Repeat step 5 9. Notice there is a new entry in your Modification log with an info column value of: { "attribute.INSTID" : { "after" : "1234", "before" : "" } } 10. Repeat step 5 and notice another new entry in the Modification log with an empty "before" value 11. Apply patch 12. Repeat step 5 and notice no new entry in the Modification log 13. Edit your csv and change the patron_attributes value to: INSTID:5678 14. Repeat step 5 and notice the new modification log entry with an info column value of: { "attribute.INSTID" : { "after" : "5678", "before" : "1234" } } 15. Add another new patron attribute type to your Koha named 'home' 16. edit your csv and change the patron_attributes value to: INSTID:5678,home:town 17. Repeat step 5 18. Notice a new Modification log entry with the value of: { "attribute.home" : { "after" : "town", "before" : "" } } Sponsored-by: Auckland University of Technology Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- Koha/Patrons/Import.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm index 976ffb8f370..9c043ef05c9 100644 --- a/Koha/Patrons/Import.pm +++ b/Koha/Patrons/Import.pm @@ -377,9 +377,6 @@ LINE: while ( my $borrowerline = <$handle> ) { $patron_attributes = $patron->extended_attributes->merge_and_replace_with($patron_attributes); } - - # We do not want to filter by branch, maybe we should? - Koha::Patrons->find($borrowernumber)->extended_attributes->delete; $patron->extended_attributes($patron_attributes); } $overwritten++; -- 2.52.0