Bugzilla – Attachment 173642 Details for
Bug 31224
Koha::Biblio::Metadata->record should use the EmbedItems filter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31224: Expand coded values using metadata_record in Server.pm
Bug-31224-Expand-coded-values-using-metadatarecord.patch (text/plain), 7.66 KB, created by
Jonathan Druart
on 2024-10-29 13:06:53 UTC
(
hide
)
Description:
Bug 31224: Expand coded values using metadata_record in Server.pm
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-10-29 13:06:53 UTC
Size:
7.66 KB
patch
obsolete
>From 0c52a078d18f341ea8d3cbfbba1a915f9e249724 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 28 Oct 2024 16:26:15 -0300 >Subject: [PATCH] Bug 31224: Expand coded values using metadata_record in > Server.pm > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/OAI/Server/Repository.pm | 19 +++---------- > t/db_dependent/OAI/Server.t | 52 ++++++++++++++--------------------- > 2 files changed, 25 insertions(+), 46 deletions(-) > >diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm >index 84115a4c651..f728a67b828 100644 >--- a/Koha/OAI/Server/Repository.pm >+++ b/Koha/OAI/Server/Repository.pm >@@ -188,8 +188,9 @@ sub get_biblio_marcxml { > eval { > $record = $biblio->metadata_record( > { >- embed_items => $with_items, >- interface => 'opac' >+ embed_items => $with_items, >+ expand_coded_values => $expanded_avs, >+ interface => 'opac' > } > ); > }; >@@ -209,19 +210,7 @@ sub get_biblio_marcxml { > > #TODO: Also hide record if OpacSuppression is in use > } >- if ( $record && $expanded_avs ) { >- my $frameworkcode = GetFrameworkCode($biblionumber) || ''; >- my $record_processor = Koha::RecordProcessor->new( >- { >- filters => [ 'ExpandCodedFields' ], >- options => { >- interface => 'opac', >- frameworkcode => $frameworkcode >- } >- } >- ); >- $record_processor->process($record); >- } >+ > return ( $record ? $record->as_xml_record( C4::Context->preference('marcflavour') ) : undef, $decoding_error ); > } > >diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t >index 04f96915ca7..5da76b4f36d 100755 >--- a/t/db_dependent/OAI/Server.t >+++ b/t/db_dependent/OAI/Server.t >@@ -106,7 +106,7 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { > $timestamp .= 'Z'; > $timestamp =~ s/ /T/; > my $biblio = Koha::Biblios->find($biblionumber); >- $record = $biblio->metadata->record; >+ $record = $biblio->metadata_record; > my $record_transformed = $record->clone; > $record_transformed->delete_fields( $record_transformed->field('952')); > $record_transformed = XMLin($record_transformed->as_xml_record); >@@ -394,7 +394,7 @@ subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_me > # Modify record to trigger auto update of timestamp > (my $biblionumber = $marcxml[0]->{header}->{identifier}) =~ s/^.*:(.*)/$1/; > my $biblio = Koha::Biblios->find($biblionumber); >- my $record = $biblio->metadata->record; >+ my $record = $biblio->metadata_record; > $record->append_fields(MARC::Field->new(999, '', '', z => '_')); > ModBiblio( $record, $biblionumber ); > my $from_dt = dt_from_string( >@@ -546,8 +546,10 @@ subtest 'Tests for OpacHiddenItems' => sub { > datestamp => $utc_timestamp, > identifier => 'TEST:' . $item->biblionumber > }, >- metadata => >- { record => XMLin( $biblio->metadata->record( { embed_items => 1, opac => 1 } )->as_xml_record() ) } >+ metadata => { >+ record => >+ XMLin( $biblio->metadata_record( { embed_items => 1, interface => 'opac' } )->as_xml_record() ) >+ } > } > }; > my $expected_hidden = { >@@ -648,27 +650,22 @@ subtest 'Tests for timestamp handling' => sub { > my $expected = { > record => { > header => { >- datestamp => $utc_timestamp, >+ datestamp => $utc_timestamp, > identifier => 'TEST:' . $biblio1->biblionumber > }, > metadata => { >- record => XMLin( >- $biblio1->metadata->record({ embed_items => 1, opac => 1})->as_xml_record() >- ) >+ record => >+ XMLin( $biblio1->metadata_record( { embed_items => 1, interface => 'opac' } )->as_xml_record() ) > } > } > }; > my $expected_no_items = { > record => { > header => { >- datestamp => $utc_timestamp, >+ datestamp => $utc_timestamp, > identifier => 'TEST:' . $biblio1->biblionumber > }, >- metadata => { >- record => XMLin( >- $biblio1->metadata->record({opac => 1})->as_xml_record() >- ) >- } >+ metadata => { record => XMLin( $biblio1->metadata_record( { interface => 'opac' } )->as_xml_record() ) } > } > }; > >@@ -724,9 +721,8 @@ subtest 'Tests for timestamp handling' => sub { > $sth_item->execute($timestamp, $item2->itemnumber); > > $expected->{record}{header}{datestamp} = $utc_timestamp; >- $expected->{record}{metadata}{record} = XMLin( >- $biblio1->metadata->record({ embed_items => 1, opac => 1})->as_xml_record() >- ); >+ $expected->{record}{metadata}{record} = >+ XMLin( $biblio1->metadata_record( { embed_items => 1, interface => 'opac' } )->as_xml_record() ); > > test_query( > 'ListRecords - biblio with two items', >@@ -790,9 +786,8 @@ subtest 'Tests for timestamp handling' => sub { > $sth_del_item->execute($timestamp, $item1->itemnumber); > > $expected->{record}{header}{datestamp} = $utc_timestamp; >- $expected->{record}{metadata}{record} = XMLin( >- $biblio1->metadata->record({ embed_items => 1, opac => 1})->as_xml_record() >- ); >+ $expected->{record}{metadata}{record} = >+ XMLin( $biblio1->metadata_record( { embed_items => 1, interface => 'opac' } )->as_xml_record() ); > > test_query( > 'ListRecords - biblio with existing and deleted item', >@@ -819,9 +814,8 @@ subtest 'Tests for timestamp handling' => sub { > $item2->safe_delete({ skip_record_index =>1 }); > $sth_del_item->execute($timestamp, $item2->itemnumber); > >- $expected->{record}{metadata}{record} = XMLin( >- $biblio1->metadata->record({ embed_items => 1, opac => 1})->as_xml_record() >- ); >+ $expected->{record}{metadata}{record} = >+ XMLin( $biblio1->metadata_record( { embed_items => 1, interface => 'opac' } )->as_xml_record() ); > > test_query( > 'ListRecords - biblio with two deleted items', >@@ -898,12 +892,12 @@ subtest 'Tests for timestamp handling' => sub { > $expected_header->{record}, > { > header => { >- datestamp => $utc_timestamp, >+ datestamp => $utc_timestamp, > identifier => 'TEST:' . $biblio2->biblionumber > }, > metadata => { > record => XMLin( >- $biblio2->metadata->record({ embed_items => 1, opac => 1})->as_xml_record() >+ $biblio2->metadata_record( { embed_items => 1, interface => 'opac' } )->as_xml_record() > ) > } > } >@@ -914,14 +908,10 @@ subtest 'Tests for timestamp handling' => sub { > $expected_header->{record}, > { > header => { >- datestamp => $utc_timestamp, >+ datestamp => $utc_timestamp, > identifier => 'TEST:' . $biblio2->biblionumber > }, >- metadata => { >- record => XMLin( >- $biblio2->metadata->record->as_xml_record() >- ) >- } >+ metadata => { record => XMLin( $biblio2->metadata_record( { interface => 'opac' } )->as_xml_record() ) } > } > ] > }; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31224
:
138060
|
138061
|
138062
|
138063
|
138064
|
142137
|
142138
|
142139
|
142140
|
142141
|
142142
|
142143
|
161933
|
161934
|
161935
|
161936
|
161937
|
161938
|
161939
|
161940
|
161941
|
161942
|
161943
|
161944
|
173530
|
173531
|
173532
|
173533
|
173534
|
173535
|
173588
|
173597
|
173598
|
173636
|
173637
|
173638
|
173639
|
173640
|
173641
| 173642 |
173643
|
173644
|
174262
|
174263