Bugzilla – Attachment 125725 Details for
Bug 28734
Koha::Biblio->get_marc_notes should parse authorised values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28734: Parse display in $biblio->get_marc_notes
Bug-28734-Parse-display-in-biblio-getmarcnotes.patch (text/plain), 8.94 KB, created by
Jonathan Druart
on 2021-10-05 08:57:39 UTC
(
hide
)
Description:
Bug 28734: Parse display in $biblio->get_marc_notes
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-10-05 08:57:39 UTC
Size:
8.94 KB
patch
obsolete
>From bba826c811a412078ebc0aa0a76dac7f5ed4cb7e Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Wed, 21 Jul 2021 17:01:23 +1200 >Subject: [PATCH] Bug 28734: Parse display in $biblio->get_marc_notes >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >1. Go to Koha Administration, MARC bibliographic frameworks >2. Edit a framework, find tag 590, edit the $z subfield to use an >authorised value. >3. Do a catalogue search and edit a record using this framework. Edit >590$z and select an authorised value. Save the record. >4. Add the record to your cart. >5. View your cart. Click More Details. >6. Scroll down to the Notes section. Notice the authorised value code is >displayed instead of the description. >7. Apply the patch, restart services. >8. Refresh your cart. Click More Details again if you need to. >9. Scroll down to the Notes section. The description of the authorised >value should now be displayed. > >Sponsored-by: Catalyst IT > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> > >Bug 28734: (follow-up) Use transformMARCXML4XSLT and tests > >Confirm the following tests pass: >- t/db_dependent/Koha/Biblio.t >- t/db_dependent/XSLT.t > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> > >Bug 28734: (QA follow-up) Fix test imports and readability > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> > >Bug 28734: (QA follow-up) Update documentation about function usage > >We are now using the function from Koha::Biblio. > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> > >Bug 28734: Remove unadvertised changes > >1. Using $frameworkcode instead of the default '' is an unadvertised change. >It would make sense to use $frameworkcode, but actually we must remove this parameter and always use the default, as we decided to make the default authoritative. >I would prefer to not introduce this change, just in case.. > >2. Restore good import (use plurals) >--- > C4/XSLT.pm | 19 ++++++++----------- > Koha/Biblio.pm | 6 +++++- > t/db_dependent/Koha/Biblio.t | 19 ++++++++++++++++--- > 3 files changed, 29 insertions(+), 15 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index a96d60b1ec8..864158714a5 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -31,8 +31,6 @@ use Koha::ItemTypes; > use Koha::XSLT::Base; > use Koha::Libraries; > >- >- > my $engine; #XSLT Handler object > my %authval_per_framework; > # Cache for tagfield-tagsubfield to decode per framework. >@@ -60,12 +58,11 @@ C4::XSLT - Functions for displaying XSLT-generated content > =head2 transformMARCXML4XSLT > > Replaces codes with authorized values in a MARC::Record object >-Is only used in this module currently. > > =cut > > sub transformMARCXML4XSLT { >- my ($biblionumber, $record) = @_; >+ my ($biblionumber, $record, $opac) = @_; > my $frameworkcode = GetFrameworkCode($biblionumber) || ''; > my $tagslib = &GetMarcStructure(1, $frameworkcode, { unsafe => 1 }); > my @fields; >@@ -84,7 +81,7 @@ sub transformMARCXML4XSLT { > my ( $letter, $value ) = @$subfield; > # Replace the field value with the authorised value *except* for MARC21/NORMARC field 942$n (suppression in opac) > if ( !( $tag eq '942' && $subfield->[0] eq 'n' ) || $marcflavour eq 'UNIMARC' ) { >- $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib ) >+ $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib, undef, $opac ) > if $av->{ $tag }->{ $letter }; > } > push( @new_subfields, $letter, $value ); >@@ -397,13 +394,13 @@ sub buildKohaItemsNamespace { > else { > $status = "available"; > } >- my $homebranch = xml_escape($branches{$item->homebranch}); >- my $holdingbranch = xml_escape($branches{$item->holdingbranch}); >+ my $homebranch = C4::Koha::xml_escape($branches{$item->homebranch}); >+ my $holdingbranch = C4::Koha::xml_escape($branches{$item->holdingbranch}); > my $resultbranch = C4::Context->preference('OPACResultsLibrary') eq 'homebranch' ? $homebranch : $holdingbranch; >- my $location = xml_escape($item->location && exists $shelflocations->{$item->location} ? $shelflocations->{$item->location} : $item->location); >- my $ccode = xml_escape($item->ccode && exists $ccodes->{$item->ccode} ? $ccodes->{$item->ccode} : $item->ccode); >- my $itemcallnumber = xml_escape($item->itemcallnumber); >- my $stocknumber = xml_escape($item->stocknumber); >+ my $location = C4::Koha::xml_escape($item->location && exists $shelflocations->{$item->location} ? $shelflocations->{$item->location} : $item->location); >+ my $ccode = C4::Koha::xml_escape($item->ccode && exists $ccodes->{$item->ccode} ? $ccodes->{$item->ccode} : $item->ccode); >+ my $itemcallnumber = C4::Koha::xml_escape($item->itemcallnumber); >+ my $stocknumber = C4::Koha::xml_escape($item->stocknumber); > $xml .= > "<item>" > . "<homebranch>$homebranch</homebranch>" >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 26ee7abd960..4cd70ef3880 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -24,6 +24,7 @@ use URI; > use URI::Escape qw( uri_escape_utf8 ); > > use C4::Koha qw( GetNormalizedISBN ); >+use C4::XSLT qw( transformMARCXML4XSLT ); > > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); >@@ -829,7 +830,10 @@ sub get_marc_notes { > > my %hiddenlist = map { $_ => 1 } > split( /,/, C4::Context->preference('NotesToHide')); >- foreach my $field ( $self->metadata->record->field($scope) ) { >+ my $record = $self->metadata->record; >+ $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac ); >+ >+ foreach my $field ( $record->field($scope) ) { > my $tag = $field->tag(); > next if $hiddenlist{ $tag }; > next if $opac && $maybe_private{$tag} && !$field->indicator(1); >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index 83de0634c6b..d4c9e56e815 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -22,6 +22,9 @@ use Test::More tests => 14; > use C4::Biblio qw( AddBiblio ModBiblio ); > use Koha::Database; > use Koha::Acquisition::Orders; >+use Koha::AuthorisedValueCategories; >+use Koha::AuthorisedValues; >+use Koha::MarcSubfieldStructures; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -580,7 +583,7 @@ subtest 'subscriptions() tests' => sub { > }; > > subtest 'get_marc_notes() MARC21 tests' => sub { >- plan tests => 11; >+ plan tests => 13; > > $schema->storage->txn_begin; > >@@ -594,22 +597,32 @@ subtest 'get_marc_notes() MARC21 tests' => sub { > MARC::Field->new( '520', '', '', a => 'Note3 skipped' ), > MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ), > MARC::Field->new( '541', '', '', a => 'Note5' ), >+ MARC::Field->new( '590', '', '', a => 'CODE' ), > ); >+ >+ Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store; >+ Koha::AuthorisedValue->new({ category => 'TEST', authorised_value => 'CODE', lib => 'Description should show', lib_opac => 'Description should show OPAC' })->store; >+ my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode }); >+ $mss->update({ authorised_value => "TEST" }); >+ > C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); > $biblio = Koha::Biblios->find( $biblio->biblionumber); >+ > my $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21' }); > is( $notes->[0]->{marcnote}, 'Note1', 'First note' ); > is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); > is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' ); > is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Not shows if not opac" ); > is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' ); >- is( @$notes, 5, 'No more notes' ); >+ is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' ); >+ is( @$notes, 6, 'No more notes' ); > $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21', opac => 1 }); > is( $notes->[0]->{marcnote}, 'Note1', 'First note' ); > is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); > is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' ); > is( $notes->[3]->{marcnote}, 'Note5', 'Fifth note shows after fourth skipped' ); >- is( @$notes, 4, 'No more notes' ); >+ is( $notes->[4]->{marcnote}, 'Description should show OPAC', 'Authorised value is correctly parsed for OPAC to show description rather than code' ); >+ is( @$notes, 5, 'No more notes' ); > > $schema->storage->txn_rollback; > }; >-- >2.25.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 28734
:
123016
|
123346
|
123349
|
124231
|
125574
|
125575
|
125634
|
125635
|
125660
|
125661
|
125662
|
125663
|
125687
|
125724
| 125725 |
126052