Bugzilla – Attachment 107563 Details for
Bug 25913
Internal server error when calling get_coins on record with no title (245) but with 880 linked to 245
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25913: Prevent get_coins to crash if record does not have title
Bug-25913-Prevent-getcoins-to-crash-if-record-does.patch (text/plain), 2.83 KB, created by
Jonathan Druart
on 2020-07-30 08:44:22 UTC
(
hide
)
Description:
Bug 25913: Prevent get_coins to crash if record does not have title
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-07-30 08:44:22 UTC
Size:
2.83 KB
patch
obsolete
>From fd8c2ef4543ea64b6addd95133ee50424de0e9e0 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 30 Jul 2020 10:41:45 +0200 >Subject: [PATCH] Bug 25913: Prevent get_coins to crash if record does not have > title > >If a bibliographic record does not have a title, get_coins will crash >with >Can't call method "as_string" on an undefined value at /kohadevbox/koha/Koha/Biblio.pm line 645 >Koha::Biblio::get_coins('Koha::Biblio=HASH(0x5558f91bb740)') called at /kohadevbox/koha/catalogue/ISBDdetail.pl line 144 > >We can handle that situation easily by checking the existence of the >title field. > >Test plan: >1. Create a record without 245 >2. Enable COinSinOpac >4. Go to the ISBD detail view >=> It must not fail with this patch applied >--- > Koha/Biblio.pm | 3 ++- > t/db_dependent/Koha/Biblio.t | 13 +++++++++++-- > 2 files changed, 13 insertions(+), 3 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 830b9c4d73..f430f4135a 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -642,7 +642,8 @@ sub get_coins { > push @authors, $au; > } > } >- $title = $record->field('245')->as_string('ab'); >+ $title = $record->field('245'); >+ $title &&= $title->as_string('ab'); > if ($titletype eq 'a') { > $pubyear = $record->field('008') || ''; > $pubyear = substr($pubyear->data(), 7, 4) if $pubyear; >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index b849fd3160..727c5b57de 100644 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -118,7 +118,7 @@ subtest 'items() tests' => sub { > > subtest 'get_coins and get_openurl' => sub { > >- plan tests => 3; >+ plan tests => 4; > > $schema->storage->txn_begin; > >@@ -127,13 +127,22 @@ subtest 'get_coins and get_openurl' => sub { > title => 'Title 1', > author => 'Author 1' > }); >- > is( > $biblio->get_coins, > 'ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Title%201&rft.au=Author%201', > 'GetCOinsBiblio returned right metadata' > ); > >+ my $record = MARC::Record->new(); >+ $record->append_fields( MARC::Field->new('100','','','a' => 'Author 2'), MARC::Field->new('880','','','a' => 'Something') ); >+ my $biblionumber = C4::Biblio::AddBiblio($record, ''); >+ my $biblio_no_title = Koha::Biblios->find($biblionumber); >+ is( >+ $biblio_no_title->get_coins, >+ 'ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.au=Author%202', >+ 'GetCOinsBiblio returned right metadata if biblio does not have a title' >+ ); >+ > t::lib::Mocks::mock_preference("OpenURLResolverURL", "https://koha.example.com/"); > is( > $biblio->get_openurl, >-- >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 25913
:
106476
|
107563
|
110941
|
111153
|
111366