From 52ee0b266fadf27e9d563d35bdcd49ec100d4ad3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 21 Mar 2016 15:25:41 +0000 Subject: [PATCH] [SIGNED-OFF] Bug 16056: [ALT] Do not crash when searching for an authority if zebra's index is not up-to-date Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Owen Leonard This patch fixes the error, and does so in a way which I think makes more sense than the other patch. I do no expect to see deleted record in my search results. --- 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.1.4