From 4ae80d813d6634d3cd1d8d0fb1e7a852b8151b1f Mon Sep 17 00:00:00 2001
From: Fridolin Somers <fridolin.somers@biblibre.com>
Date: Thu, 10 Aug 2023 09:32:43 -1000
Subject: [PATCH] Bug 34515: Fix encoding of MARCXML output for OAI-PMH
 (UNIMARC)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Like fixed for REST API, OAI-PMH output should be fixed to use metadata schema when building MARCXML.

Test plan :
1) Use UNIMARC database
2) Enable OAI-PMH webservice
3) Edit a biblio record to add uppercase éin title 200$a
4) Go to OAI record :
/cgi-bin/koha/oai.pl?verb=GetRecord&metadataPrefix=marcxml&identifier=xxx
=> Check encoding of title is OK
---
 Koha/OAI/Server/Repository.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm
index 273497412f..fd14255a13 100644
--- a/Koha/OAI/Server/Repository.pm
+++ b/Koha/OAI/Server/Repository.pm
@@ -206,7 +206,8 @@ sub get_biblio_marcxml {
         );
         $record_processor->process($record);
     }
-    return ( $record ? $record->as_xml_record() : undef, $decoding_error );
+    my $schema = $biblio->metadata->schema // C4::Context->preference("marcflavour");
+    return ( $record ? $record->as_xml_record($schema) : undef, $decoding_error );
 }
 
 
-- 
2.41.0