From 6c405250ca8412283dc22ed5f5558c10d7f50ba8 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 Signed-off-by: =?UTF-8?q?Micha=C5=82=20Kula?= <148193449+mkibp@users.noreply.github.com> --- 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 1493bf37a80..dbbd072b079 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -542,7 +542,9 @@ RECORD: foreach my $record (@{$marc_records}) { } } elsif ($insert) { - eval { ($record_id, $biblioitemnumber) = AddBiblio($record, $framework, { disable_autolink => 1 }) }; + my $record_clone = $record->clone(); + C4::Biblio::_strip_item_fields($record_clone); + eval { ($record_id, $biblioitemnumber) = AddBiblio($record_clone, $framework, { disable_autolink => 1 }) }; if ($@) { warn "ERROR: Insert biblio $originalid failed: $@\n"; printlog( { id => $originalid, op => "insert", status => "ERROR" } ) if ($logfile); @@ -551,6 +553,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.40.0