From 8e570825c787b78bbfbd8302fe49e25807e6c1ab Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 13 Dec 2016 12:28:35 +0000 Subject: [PATCH] [SIGNED-OFF] Bug 17764: (bug 17556 follow-up) Fix search for logged out users and lost items Content-Type: text/plain; charset="utf-8" If you are non logged-in and you the search result contain lost items, you will get: Can't call method "category" on an undefined value at /home/liz/koha-src/koha/C4/Search.pm line 2091. This is because bug 17556 assumed that $userenv was not defined when the user is logged out. Actually it is, with non defined or empty string values. Test plan: Do a search in the opac that would turn up a whole list of results (and not just that one) with the lost item included. => Without this patch you should get an error => With this patch applied you should see the search results Signed-off-by: Owen Leonard --- C4/Search.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/C4/Search.pm b/C4/Search.pm index 4d89d23..4270c82 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2090,6 +2090,7 @@ sub searchResults { my $userenv = C4::Context->userenv; if ( $item->{onloan} && $userenv + && $userenv->{number} && !( Koha::Patrons->find($userenv->{number})->category->hidelostitems && $item->{itemlost} ) ) { $onloan_count++; -- 2.1.4