Bugzilla – Attachment 125635 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: (follow-up) Use transformMARCXML4XSLT and tests
Bug-28734-follow-up-Use-transformMARCXML4XSLT-and-.patch (text/plain), 7.40 KB, created by
David Nind
on 2021-10-01 14:34:57 UTC
(
hide
)
Description:
Bug 28734: (follow-up) Use transformMARCXML4XSLT and tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-10-01 14:34:57 UTC
Size:
7.40 KB
patch
obsolete
>From a83b24476263920723dcd038513d786c4b3f7451 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Fri, 1 Oct 2021 15:41:12 +1300 >Subject: [PATCH] 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> >--- > C4/XSLT.pm | 18 ++++++++---------- > Koha/Biblio.pm | 8 ++------ > t/db_dependent/Koha/Biblio.t | 22 +++++++++++++++++++--- > 3 files changed, 29 insertions(+), 19 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index a96d60b1ec..f932c624d6 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. >@@ -65,7 +63,7 @@ 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 +82,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, $frameworkcode, $tagslib, undef, $opac ) > if $av->{ $tag }->{ $letter }; > } > push( @new_subfields, $letter, $value ); >@@ -397,13 +395,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 d80e3f0406..4cd70ef388 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -24,7 +24,7 @@ use URI; > use URI::Escape qw( uri_escape_utf8 ); > > use C4::Koha qw( GetNormalizedISBN ); >-use C4::XSLT qw( XSLTParse4Display ); >+use C4::XSLT qw( transformMARCXML4XSLT ); > > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); >@@ -831,11 +831,7 @@ sub get_marc_notes { > my %hiddenlist = map { $_ => 1 } > split( /,/, C4::Context->preference('NotesToHide')); > my $record = $self->metadata->record; >- >- my $xslfile = C4::Context->preference('XSLTDetailsDisplay') || 'default'; >- my $lang = $xslfile ? C4::Languages::getlanguage() : undef; >- my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; >- XSLTParse4Display( $self->biblionumber, $record, "XSLTDetailsDisplay", 1, undef, $sysxml, $xslfile, $lang, undef ); >+ $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac ); > > foreach my $field ( $record->field($scope) ) { > my $tag = $field->tag(); >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index 83de0634c6..ce67abe66f 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,35 @@ 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, 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, 5, 'No more notes' ); >+ >+ $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21' }); >+ is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' ); >+ $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21', opac => 1 }); >+ is( $notes->[4]->{marcnote}, 'Description should show OPAC', 'Authorised value is correctly parsed for OPAC to show description rather than code' ); > > $schema->storage->txn_rollback; > }; >-- >2.20.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