From 72f96d3e3ba744084b4548b4d0ffc4f7d4ec94b2 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=utf8 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. Signed-off-by: Katrin Fischer Signed-off-by: Brendan A Gallagher --- C4/AuthoritiesMarc.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 43c5faf53e..866350e6f0 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.39.5