From 6028156decc1962c92ad0ec13893957d3c2f3256 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 1 Aug 2024 17:37:35 +0000 Subject: [PATCH] Bug 37550: Move item check after error handling To test: 1 - Grab the sample file on this bug report 2 - perl misc/migration_tools/bulkmarcimport.pl -b --file=spaceditems.pl -v 3 - An exception for 'Duplicate ID' is thrown and script dies 4 - Apply patch 5 - run script again 6 - The script finishes, no items are added, but record is Signed-off-by: Phil Ringnalda --- misc/migration_tools/bulkmarcimport.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 8161a0bb0a..9c1f144af3 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -597,7 +597,6 @@ RECORD: foreach my $record ( @{$marc_records} ) { AddItemBatchFromMarc( $record, $record_id, $biblioitemnumber, $framework ); }; my $error_adding = $@; - $record_has_added_items = @{$itemnumbers_ref}; if ($error_adding) { warn "ERROR: Adding items to bib $record_id failed: $error_adding"; @@ -607,6 +606,9 @@ RECORD: foreach my $record ( @{$marc_records} ) { # the MARC columns in biblioitems were not set. next RECORD; } + + $record_has_added_items = @{$itemnumbers_ref}; + if ( $dedup_barcode && grep { exists $_->{error_code} && $_->{error_code} eq 'duplicate_barcode' } @$errors_ref ) { -- 2.44.0