From b09c63f7d6b5b8f86fb9f6914d75731b4e368893 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 21 Mar 2016 15:25:41 +0000 Subject: [PATCH] Bug 16056: [ALT] Do not crash when searching for an authority if zebra's index is not up-to-date This patch fixes a regression introduced by commit 7e70202d34d75f988fbaea9b911347417c203aac Bug 15381: Remove GetAuthType and GetAuthTypeCode This second version will change the original behavior: If an authority record is still indexed by zebra but not in the DB, it won't be displayed. Test plan: Search for authorities delete one The results won't contain the record you have deleted. --- C4/AuthoritiesMarc.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index a88d4fa..47e83e6 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -302,7 +302,13 @@ sub SearchAuthorities { } } - my $thisauthtypecode = Koha::Authorities->find($authid)->authtypecode; + my $authority = Koha::Authorities->find($authid); + unless ( $authority ) { + # The authority does not exist in the DB: Zebra's index is outdated + $counter++; + next; + } + my $thisauthtypecode = $authority->authtypecode; my $thisauthtype = Koha::Authority::Types->find($thisauthtypecode); unless (defined $thisauthtype) { $thisauthtypecode = $authtypecode; -- 2.7.0