From f3603ab9dcc34823906fa8e2f8a2071479c6d124 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 12 Jan 2022 21:05:29 -1000 Subject: [PATCH] Bug 29871: Remove marcflavour param in Koha::Biblio->get_marc_notes Test plan : Display a biblio record with some MARC notes in details page and basket, OPAC and staff Run prove t/db_dependent/Koha/Biblio.t Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit b74ce12b8566ddab1149a82a9aa9b071f2586803) Signed-off-by: Lucas Gass --- Koha/Biblio.pm | 4 ++-- basket/basket.pl | 2 +- catalogue/detail.pl | 28 ++++++++++++++-------------- opac/opac-basket.pl | 2 +- opac/opac-detail.pl | 2 +- t/db_dependent/Koha/Biblio.t | 6 ++++-- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 087efc78a6..b7431f5c26 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -913,7 +913,7 @@ sub cover_images { =head3 get_marc_notes - $marcnotesarray = $biblio->get_marc_notes({ marcflavour => $marcflavour }); + $marcnotesarray = $biblio->get_marc_notes({ opac => 1 }); Get all notes from the MARC record and returns them in an array. The notes are stored in different fields depending on MARC flavour. @@ -924,7 +924,7 @@ MARC21 5XX $u subfields receive special attention as they are URIs. sub get_marc_notes { my ( $self, $params ) = @_; - my $marcflavour = $params->{marcflavour}; + my $marcflavour = C4::Context->preference('marcflavour'); my $opac = $params->{opac}; my $scope = $marcflavour eq "UNIMARC"? '3..': '5..'; diff --git a/basket/basket.pl b/basket/basket.pl index 92f6561c9c..fdcc2c8559 100755 --- a/basket/basket.pl +++ b/basket/basket.pl @@ -68,7 +68,7 @@ foreach my $biblionumber ( @bibs ) { my $biblio = Koha::Biblios->find( $biblionumber ) or next; my $dat = $biblio->unblessed; my $record = &GetMarcBiblio({ biblionumber => $biblionumber }); - my $marcnotesarray = $biblio->get_marc_notes({ marcflavour => $marcflavour }); + my $marcnotesarray = $biblio->get_marc_notes; my $marcauthorsarray = $biblio->get_marc_authors; my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); my $marcseriesarray = GetMarcSeries ($record,$marcflavour); diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 502963f8d6..e4d84aa0ea 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -464,21 +464,21 @@ $template->param( ); $template->param( - MARCNOTES => $marc_record ? $biblio->get_marc_notes({ marcflavour => $marcflavour }) : undef, - itemdata_ccode => $itemfields{ccode}, - itemdata_enumchron => $itemfields{enumchron}, - itemdata_uri => $itemfields{uri}, - itemdata_copynumber => $itemfields{copynumber}, - itemdata_stocknumber => $itemfields{stocknumber}, - itemdata_publisheddate => $itemfields{publisheddate}, - volinfo => $itemfields{enumchron}, - itemdata_itemnotes => $itemfields{itemnotes}, - itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic}, - z3950_search_params => C4::Search::z3950_search_args($dat), - hostrecords => $hostrecords, - analytics_flag => $analytics_flag, + MARCNOTES => $marc_record ? $biblio->get_marc_notes() : undef, + itemdata_ccode => $itemfields{ccode}, + itemdata_enumchron => $itemfields{enumchron}, + itemdata_uri => $itemfields{uri}, + itemdata_copynumber => $itemfields{copynumber}, + itemdata_stocknumber => $itemfields{stocknumber}, + itemdata_publisheddate => $itemfields{publisheddate}, + volinfo => $itemfields{enumchron}, + itemdata_itemnotes => $itemfields{itemnotes}, + itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic}, + z3950_search_params => C4::Search::z3950_search_args($dat), + hostrecords => $hostrecords, + analytics_flag => $analytics_flag, C4::Search::enabled_staff_search_views, - materials => $materials_flag, + materials => $materials_flag, ); if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) { diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl index 18737d7044..fe54ca75b6 100755 --- a/opac/opac-basket.pl +++ b/opac/opac-basket.pl @@ -90,7 +90,7 @@ foreach my $biblionumber ( @bibs ) { }); $record_processor->process($record); next unless $record; - my $marcnotesarray = $biblio->get_marc_notes({ marcflavour => $marcflavour, opac => 1 }); + my $marcnotesarray = $biblio->get_marc_notes({ opac => 1 }); my $marcauthorsarray = $biblio->get_marc_authors; my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); my $marcseriesarray = GetMarcSeries ($record,$marcflavour); diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index f8c2371f76..000eac3a51 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -797,7 +797,7 @@ if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) { } } -my $marcnotesarray = $biblio->get_marc_notes({ marcflavour => $marcflavour, opac => 1 }); +my $marcnotesarray = $biblio->get_marc_notes({ opac => 1 }); if( C4::Context->preference('ArticleRequests') ) { my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef; diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 3065eae646..fc8445545d 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -699,7 +699,7 @@ subtest 'get_marc_notes() MARC21 tests' => sub { C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); $biblio = Koha::Biblios->find( $biblio->biblionumber); - my $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21' }); + my $notes = $biblio->get_marc_notes; is( $notes->[0]->{marcnote}, 'Note1', 'First note' ); is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' ); @@ -707,7 +707,7 @@ subtest 'get_marc_notes() MARC21 tests' => sub { is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' ); 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 }); + $notes = $biblio->get_marc_notes({ 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' ); @@ -729,6 +729,7 @@ subtest 'get_marc_notes() UNIMARC tests' => sub { $schema->storage->txn_begin; t::lib::Mocks::mock_preference( 'NotesToHide', '310' ); + t::lib::Mocks::mock_preference( 'marcflavour', 'UNIMARC' ); my $biblio = $builder->build_sample_biblio; my $record = $biblio->metadata->record; @@ -744,6 +745,7 @@ subtest 'get_marc_notes() UNIMARC tests' => sub { is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); is( @$notes, 2, 'No more notes' ); + t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); $schema->storage->txn_rollback; }; -- 2.39.5