From e3663c59299991ea0bed936e38e7f18f532cc655 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Fri, 22 Nov 2013 11:00:21 +0100 Subject: [PATCH] [Signed-off] Bug 9578 - Error when search and sort not on relevance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When searching with a sort (means not by relevance) and there is an error in Zebra connexion (server is down or query is wrong), you get the message : Error : Can't call method "sort" on an undefined value at /home/kohaadmin/src/C4/Search.pm line 405. This patch corrects by not performing sort if no results. Steps to reproduce the error without patch: In OPAC go to Advanced Search Choose "Title" in first "Search for:" end enter fgdfgdfgdggdg (Exam 70-433) Display "More options" Set "Sort by" to "Title (A-Z)" Click "Search" at bootom of page Result: Error: Can't call method "sort" on an undefined value at /usr/share/kohaclone/C4/Search.pm line 430. Test plan : - Set OPACdefaultSortField on something else than relevance - Perform a simple search with a wrong CCL query. For example : ccl=( and ) => You get the messge : No results found ... Patch behaves as expected. Signed-off-by: Marc VĂ©ron --- C4/Search.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Search.pm b/C4/Search.pm index 09c1951..80fd0c8 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -426,7 +426,7 @@ sub getRecords { warn "Ignoring unrecognized sort '$sort' requested" if $sort_by; } } - if ($sort_by && !$scan) { + if ( $sort_by && !$scan && $results[$i] ) { if ( $results[$i]->sort( "yaz", $sort_by ) < 0 ) { warn "WARNING sort $sort_by failed"; } -- 1.7.10.4