From d3005a2a4c493c624ffd6204f6fccc83ea350361 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 1 Feb 2021 13:22:58 -0500 Subject: [PATCH] Bug 27586: Import patrons script has a confirm switch that doesn't nothing! If the script misc/import_patrons.pl is run without "--confirm" it reports that it is "running in dry-run mode" but it is not! Test Plan: 1) Import a CSV of patrons using import_patrons.pm *without* the --confirm parameter 2) Note that it does actually import the patrons 3) Apply this patch 4) Note that this time the patrons are not actually imported 5) Import again with --confirm 6) Note that the patrons were actually imported this time! Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- Koha/Patrons/Import.pm | 6 ++++++ misc/import_patrons.pl | 1 + 2 files changed, 7 insertions(+) diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm index 7839c4fb85..6f5646a416 100644 --- a/Koha/Patrons/Import.pm +++ b/Koha/Patrons/Import.pm @@ -73,9 +73,13 @@ sub import_patrons { my $ext_preserve = $params->{preserve_extended_attributes}; my $overwrite_cardnumber = $params->{overwrite_cardnumber}; my $overwrite_passwords = $params->{overwrite_passwords}; + my $dry_run = $params->{dry_run}; my $extended = C4::Context->preference('ExtendedPatronAttributes'); my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences'); + my $schema = Koha::Database->new->schema; + $schema->storage->txn_begin if $dry_run; + my @columnkeys = $self->set_column_keys($extended); my @feedback; my @errors; @@ -425,6 +429,8 @@ sub import_patrons { invalid => $invalid, imported_borrowers => \@imported_borrowers, }; + + $schema->storage->txn_rollback if $dry_run; } =head2 prepare_columns diff --git a/misc/import_patrons.pl b/misc/import_patrons.pl index b341308c68..b3bbb66e87 100755 --- a/misc/import_patrons.pl +++ b/misc/import_patrons.pl @@ -65,6 +65,7 @@ my $return = $Import->import_patrons( overwrite_cardnumber => $overwrite_cardnumber, overwrite_passwords => $overwrite_passwords, preserve_extended_attributes => $ext_preserve, + dry_run => !$confirm, } ); -- 2.39.5