From 6aa7118c1386b81c1c5124f80d7307d77302ca2c Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Fri, 12 Nov 2021 23:42:30 +0100 Subject: [PATCH] Bug 25539: Strip items when adding new biblio to preserve previous behaviour of the script MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Kula <148193449+mkibp@users.noreply.github.com> Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- misc/migration_tools/bulkmarcimport.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 9166f4d0df..082fcfeff1 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -546,7 +546,9 @@ RECORD: foreach my $record (@{$marc_records}) { } } elsif ($insert) { - eval { ($record_id, $biblioitemnumber) = AddBiblio($record, $framework, $add_biblio_options) }; + my $record_clone = $record->clone(); + C4::Biblio::_strip_item_fields($record_clone); + eval { ($record_id, $biblioitemnumber) = AddBiblio($record_clone, $framework, $add_biblio_options) }; if ($@) { warn "ERROR: Insert biblio $originalid failed: $@\n"; printlog( { id => $originalid, op => "insert", status => "ERROR" } ) if ($logfile); @@ -555,6 +557,11 @@ RECORD: foreach my $record (@{$marc_records}) { else { printlog( { id => $originalid, op => "insert", status => "ok" } ) if ($logfile); } + # If incoming record has bib ids set we need to transfer + # new ids from record_clone to incoming record to avoid + # working on wrong record (the original record) later on + # when adding items for example + C4::Biblio::_koha_marc_update_bib_ids($record, $framework, $record_id, $biblioitemnumber); } else { warn "WARNING: Insert biblio $originalid skipped"; -- 2.39.5