From 336951673cb5c0700f2408dabc8c87b2cc9ea051 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 25 Jul 2022 14:26:27 +0200 Subject: [PATCH] Bug 29697: Fix t/db_dependent/Exporter/Record.t Not sure about the warn, we shouldn't need it as we are raising an exception. But better (for now) than introducing regressions. Signed-off-by: Tomas Cohen Arazi --- C4/Record.pm | 5 ++++- Koha/Biblio/Metadata.pm | 1 + Koha/Exporter/Record.pm | 12 ++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/C4/Record.pm b/C4/Record.pm index 3de35a27fc..69a60f3520 100644 --- a/C4/Record.pm +++ b/C4/Record.pm @@ -460,7 +460,10 @@ sub marcrecord2csv { # Getting the record my $biblio = Koha::Biblios->find($biblionumber); return unless $biblio; - my $record = $biblio->metadata->record({ embed_items => 1, itemnumbers => $itemnumbers }); + my $record = eval { + $biblio->metadata->record( + { embed_items => 1, itemnumbers => $itemnumbers } ); + }; return unless $record; # Getting the framework my $frameworkcode = $biblio->frameworkcode; diff --git a/Koha/Biblio/Metadata.pm b/Koha/Biblio/Metadata.pm index ad451797e5..78361ab261 100644 --- a/Koha/Biblio/Metadata.pm +++ b/Koha/Biblio/Metadata.pm @@ -111,6 +111,7 @@ sub record { my $marcxml_error = $@; chomp $marcxml_error; unless ($record) { + warn $marcxml_error; Koha::Exceptions::Metadata::Invalid->throw( id => $self->id, biblionumber => $self->biblionumber, diff --git a/Koha/Exporter/Record.pm b/Koha/Exporter/Record.pm index 1716e9c9a1..e678c36ee1 100644 --- a/Koha/Exporter/Record.pm +++ b/Koha/Exporter/Record.pm @@ -127,10 +127,14 @@ sub _get_biblio_for_export { return if $@ or not defined $record; if ($export_items) { - C4::Biblio::EmbedItemsInMarcBiblio({ - marc_record => $record, - biblionumber => $biblionumber, - item_numbers => $itemnumbers }); + Koha::Biblio::Metadata->record( + { + record => $record, + embed_items => 1, + biblionumber => $biblionumber, + item_numbers => $itemnumbers, + } + ); if ($only_export_items_for_branches && @$only_export_items_for_branches) { my %export_items_for_branches = map { $_ => 1 } @$only_export_items_for_branches; my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField( 'items.homebranch' ); -- 2.39.5