Bugzilla – Attachment 122475 Details for
Bug 20310
Article requests: Use details from the host record when submitting an article request on an analytic record without attached items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20310: (follow-up) Rename method to get_marc_host
Bug-20310-follow-up-Rename-method-to-getmarchost.patch (text/plain), 5.36 KB, created by
Martin Renvoize (ashimema)
on 2021-06-28 13:14:54 UTC
(
hide
)
Description:
Bug 20310: (follow-up) Rename method to get_marc_host
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-06-28 13:14:54 UTC
Size:
5.36 KB
patch
obsolete
>From 37961dcd713565a1a7bf81e31cacb0b9a3601a0b Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 28 Jun 2021 14:13:07 +0100 >Subject: [PATCH] Bug 20310: (follow-up) Rename method to get_marc_host > >This method is a mix of database relationship accessor and marc field >accessor. We have get_marc_notes already and other patches in the queue >are also starting to introduce get_marc_* named methods. This patch >updates the method name to conform with that scheme. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Biblio.pm | 8 ++++---- > opac/opac-request-article.pl | 2 +- > t/db_dependent/Koha/Biblio/host_record.t | 24 ++++++++++++------------ > 3 files changed, 17 insertions(+), 17 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 3b38a82ce0..be9561f583 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -891,11 +891,11 @@ sub to_api_mapping { > }; > } > >-=head3 host_record >+=head3 get_marc_host > >- $host = $biblio->host_record; >+ $host = $biblio->get_marc_host; > # OR: >- ( $host, $relatedparts ) = $biblio->host_record; >+ ( $host, $relatedparts ) = $biblio->get_marc_host; > > Returns host biblio record from MARC21 773 (undef if no 773 present). > It looks at the first 773 field with MARCorgCode or only a control >@@ -906,7 +906,7 @@ sub to_api_mapping { > > =cut > >-sub host_record { >+sub get_marc_host { > my ($self, $params) = @_; > my $no_items = $params->{no_items}; > return if C4::Context->preference('marcflavour') eq 'UNIMARC'; # TODO >diff --git a/opac/opac-request-article.pl b/opac/opac-request-article.pl >index 6da39f8c8e..8a40b8f14a 100755 >--- a/opac/opac-request-article.pl >+++ b/opac/opac-request-article.pl >@@ -81,7 +81,7 @@ if ( $action eq 'create' ) { > } > elsif ( !$action && C4::Context->preference('ArticleRequestsHostRedirection') ) { > # Conditions: no items, host item entry (MARC21 773) >- my ( $host, $pageinfo ) = $biblio->host_record( { no_items => 1 } ); >+ my ( $host, $pageinfo ) = $biblio->get_marc_host( { no_items => 1 } ); > if ($host) { > $template->param( > pageinfo => $pageinfo, >diff --git a/t/db_dependent/Koha/Biblio/host_record.t b/t/db_dependent/Koha/Biblio/host_record.t >index 59b9f139e6..505efe0b95 100755 >--- a/t/db_dependent/Koha/Biblio/host_record.t >+++ b/t/db_dependent/Koha/Biblio/host_record.t >@@ -35,7 +35,7 @@ my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > our $builder = t::lib::TestBuilder->new; > >-subtest 'host_record' => sub { >+subtest 'get_marc_host' => sub { > plan tests => 11; > > t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); >@@ -58,40 +58,40 @@ subtest 'host_record' => sub { > $search_mod->mock( 'new', sub { return $engine; } ); > > # Case 1: Search engine does not return any results on controlnumber >- is( $bib1->host_record, undef, 'Empty MARC record' ); >+ is( $bib1->get_marc_host, undef, 'Empty MARC record' ); > $marc->append_fields( > MARC::Field->new( '773', '', '', g => 'relpart', w => '(xyz)123' ), > ); >- is( $bib1->host_record, undef, '773 looks fine, but no search results' ); >+ is( $bib1->get_marc_host, undef, '773 looks fine, but no search results' ); > > # Case 2: Search engine returns (at maximum) one result > $results = [ $bib1->biblionumber ]; # will be found because 773w is in shape >- my $host = $bib1->host_record; >+ my $host = $bib1->get_marc_host; > is( ref( $host ), 'Koha::Biblio', 'Correct object returned' ); > is( $host->biblionumber, $bib1->biblionumber, 'Check biblionumber' ); > $marc->field('773')->update( w => '(xyz) bad data' ); # causes no results >- $host = $bib1->host_record; >- is( $bib1->host_record, undef, 'No results for bad 773' ); >+ $host = $bib1->get_marc_host; >+ is( $bib1->get_marc_host, undef, 'No results for bad 773' ); > # Add second 773 > $marc->append_fields( MARC::Field->new( '773', '', '', g => 'relpart2', w => '234' ) ); >- $host = $bib1->host_record; >+ $host = $bib1->get_marc_host; > is( $host->biblionumber, $bib1->biblionumber, 'Result triggered by second 773' ); > # Replace orgcode > ($marc->field('773'))[1]->update( w => '(abc)345' ); >- is( $bib1->host_record, undef, 'No results for two 773s' ); >+ is( $bib1->get_marc_host, undef, 'No results for two 773s' ); > # Test no_items flag > ($marc->field('773'))[1]->update( w => '234' ); # restore >- $host = $bib1->host_record({ no_items => 1 }); >+ $host = $bib1->get_marc_host({ no_items => 1 }); > is( $host->biblionumber, $bib1->biblionumber, 'Record found with no_items' ); > $builder->build({ source => 'Item', value => { biblionumber => $bib1->biblionumber } }); >- is( $bib1->host_record({ no_items => 1 }), undef, 'Record not found with no_items flag after adding one item' ); >+ is( $bib1->get_marc_host({ no_items => 1 }), undef, 'Record not found with no_items flag after adding one item' ); > # Test list context >- my @temp = $bib1->host_record; >+ my @temp = $bib1->get_marc_host; > is( $temp[1], 'relpart2', 'Return $g in list context' ); > > # Case 3: Search engine returns more results > $results = [ 1, 2 ]; >- is( $bib1->host_record, undef, 'host_record returns undef for non-unique control number' ); >+ is( $bib1->get_marc_host, undef, 'get_marc_host returns undef for non-unique control number' ); > }; > > sub mocked_search { >-- >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 20310
:
73142
|
73143
|
73805
|
73998
|
74000
|
74992
|
74993
|
74994
|
88887
|
88888
|
88889
|
109750
|
109751
|
109752
|
109753
|
111467
|
111468
|
111469
|
111470
|
118976
|
118977
|
118978
|
118979
|
119346
|
122469
|
122470
|
122471
|
122472
|
122473
|
122474
|
122475
|
122725
|
122726
|
122727
|
122728
|
122729
|
122730
|
122731
|
122732