From 30adc19756d35a966e7f5c565ceab4f7ddeb30e1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 5 Jan 2016 10:23:16 +0000 Subject: [PATCH] Bug 15467: If authtypecode is not defined, do not explode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test t/db_dependent/AuthoritiesMarc.t fails because one test expect the BuildSummary subroutine to not crash if the authtypecode passed in parameter does not exist in the DB. Test plan: prove t/db_dependent/AuthoritiesMarc.t should return green. Signed-off-by: Frédéric Demians Test fails before patch, and doesn't anymore after. --- C4/AuthoritiesMarc.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 43c5faf..866350e 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -855,15 +855,17 @@ sub BuildSummary { # handle $authtypecode is NULL or eq "" if ($authtypecode) { my $authref = Koha::Authority::Types->find($authtypecode); - $summary{authtypecode} = $authref->authtypecode; - $summary{type} = $authref->authtypetext; - $summary_template = $authref->summary; - # for MARC21, the authority type summary displays a label meant for - # display - if (C4::Context->preference('marcflavour') ne 'UNIMARC') { - $summary{label} = $authref->summary; - } else { - $summary{summary} = $authref->summary; + if ( $authref ) { + $summary{authtypecode} = $authref->authtypecode; + $summary{type} = $authref->authtypetext; + $summary_template = $authref->summary; + # for MARC21, the authority type summary displays a label meant for + # display + if (C4::Context->preference('marcflavour') ne 'UNIMARC') { + $summary{label} = $authref->summary; + } else { + $summary{summary} = $authref->summary; + } } } my $marc21subfields = 'abcdfghjklmnopqrstuvxyz68'; -- 2.6.2