From a8f040a57439dfcf9f5b960b7ae479d43e9fc6cd Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 23 Mar 2023 20:16:37 -0300 Subject: [PATCH] Bug 32336: (QA follow-up) Use $metadata->schema When we worked on Koha::Biblio::Metadata, we agreed biblio_metadata.schema would be the sourceof truth when it comes to the record schema. This patch acknowledges that, while retaining the fallback to the syspref. To test: 1. Apply this patch 2. Run: $ prove t/db_dependent/api/v1/biblios.t => SUCCESS: Tests pass, behavior is unchanged. 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/Biblios.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm index 530df09be7b..baf9d943be7 100644 --- a/Koha/REST/V1/Biblios.pm +++ b/Koha/REST/V1/Biblios.pm @@ -67,14 +67,15 @@ sub get { ); } else { - my $record = $biblio->metadata->record; - my $marcflavour = C4::Context->preference("marcflavour"); + my $metadata = $biblio->metadata; + my $record = $metadata->record; + my $schema = $metadata->schema // C4::Context->preference("marcflavour"); $c->respond_to( marcxml => { status => 200, format => 'marcxml', - text => $record->as_xml_record($marcflavour), + text => $record->as_xml_record($schema), }, mij => { status => 200, @@ -169,7 +170,8 @@ sub get_public { return try { - my $record = $biblio->metadata->record; + my $metadata = $biblio->metadata; + my $record = $metadata->record; my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems'); my $patron = $c->stash('koha.user'); @@ -189,7 +191,7 @@ sub get_public { } } - my $marcflavour = C4::Context->preference("marcflavour"); + my $schema = $metadata->schema // C4::Context->preference("marcflavour"); my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy', @@ -205,7 +207,7 @@ sub get_public { marcxml => { status => 200, format => 'marcxml', - text => $record->as_xml_record($marcflavour), + text => $record->as_xml_record($schema), }, mij => { status => 200, -- 2.40.0