Bug 9578

Summary: Error when search and sort not on relevance
Product: Koha Reporter: Michal Dudzik <dudzikmichal>
Component: SearchingAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: dpavlin, fridolin.somers, gmcharlt, kyle, veron
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Trivial patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 9578 - Error when search and sort not on relevance
[Signed-off] Bug 9578 - Error when search and sort not on relevance
[PASSED QA] Bug 9578 - Error when search and sort not on relevance

Description Michal Dudzik 2013-02-09 10:50:57 UTC
When search eg. phrase "fgdfgdfgdggdg (Exam 70-433)" and set sorting Title or Dates or Call number or Author or Popularity Gets error:
Can not call method "sort" on an undefined value at / home/magnus/kohahead/C4/Search.pm line 407th
Comment 1 Dobrica Pavlinusic 2013-08-30 12:55:30 UTC
I can't reproduce this problem on current master. I'm not sure, but my suspicion is that it was fixed by Bug 4393: Scan Indexes results cannot be sorted
Comment 2 Fridolin Somers 2013-11-22 10:11:58 UTC Comment hidden (obsolete)
Comment 3 Marc Véron 2014-03-06 07:55:05 UTC
Steps to reproduce the error:

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.
Comment 4 Marc Véron 2014-03-06 11:57:42 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2014-03-23 20:51:43 UTC
Created attachment 26527 [details] [review]
[PASSED QA] Bug 9578 - Error when search and sort not on relevance

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 <veron@veron.ch>

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Adds another check to prevent a bad Zebra error message.
Works as described, passes all tests and QA script.
Comment 6 Galen Charlton 2014-04-18 22:35:14 UTC
Pushed to master, along with a regression test.  Thanks, Fridolin!
Comment 7 Fridolin Somers 2014-08-06 12:21:58 UTC
Pushed to 3.14.x, will be in 3.14.10
Comment 8 Kyle M Hall (khall) 2014-08-13 15:35:33 UTC
Picked for 3.12.15!