Bug 9212

Summary: Parentheses in subject headings break search
Product: Koha Reporter: Kyle M Hall <kyle>
Component: SearchingAssignee: Kyle M Hall <kyle>
Status: RESOLVED DUPLICATE QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P3 CC: chris, gbarna, jdemuth, katrin.fischer, liz, m.de.rooy, nengard
Version: master   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=1807
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9687
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 9212 - Parentheses in subject headings break search
Bug 9212 - Parentheses in subject headings break search
Bug 9212 - Parentheses in subject headings break search

Description Kyle M Hall 2012-12-04 18:43:40 UTC
Click a subject link such as "SAS (Computer program language)" gives the error:

Error:
Can't call method "sort" on an undefined value at /home/koha/kohaclone/C4/Search.pm line 404.
Comment 1 Kyle M Hall 2012-12-04 18:44:15 UTC Comment hidden (obsolete)
Comment 2 Owen Leonard 2012-12-26 16:37:23 UTC
You don't say what the context for this error is--OPAC or staff client, XSLT or non-XSLT--but I can't reproduce the error. I tested with this record: http://lccn.loc.gov/2011019323
Comment 3 Owen Leonard 2013-01-08 19:40:07 UTC
I'm marking this as failed QA simply because it's not testable without more details. Please resubmit the patch with a detailed commit message including a test plan.
Comment 4 gbarna 2013-02-19 20:46:06 UTC
(In reply to comment #0)
> Click a subject link such as "SAS (Computer program language)" gives the
> error:
> 
> Error:
> Can't call method "sort" on an undefined value at
> /home/koha/kohaclone/C4/Search.pm line 404.



Our library has the same issue. We have upgraded to 3.10 and when clicking on, for example, Ellis Island Immigration Station (N.Y. and N.J.), we get the following error message: 

Error:
Can't call method "sort" on an undefined value at /home/koha/kohaclone/C4/Search.pm line 407.
Comment 5 Kyle M Hall 2013-02-20 18:58:08 UTC
Test Plan:
1) In the OPAC, try clicking a subject link that contains parentheses, you should get an error
2) Apply the patch
3) Repeat step 1, this time it should work correctly.
Comment 6 gbarna 2013-02-25 14:13:30 UTC
(In reply to comment #5)
> Test Plan:
> 1) In the OPAC, try clicking a subject link that contains parentheses, you
> should get an error
> 2) Apply the patch
> 3) Repeat step 1, this time it should work correctly.



I applied the patch and repeated step 1. Problem was not solved. :-(
Comment 7 Kyle M Hall 2013-03-11 17:09:33 UTC Comment hidden (obsolete)
Comment 8 Liz Rea 2013-03-14 08:07:03 UTC
Created attachment 16105 [details] [review]
Bug 9212 - Parentheses in subject headings break search

Subjects links for subjects with parentheses will not give any results.

Test Plan:
1) In the OPAC, try clicking a subject link that contains parentheses, you should get an error
2) Apply the patch
3) Repeat step 1, this time it should work correctly.

Signed-off-by: Liz Rea <liz@catalyst.net.nz>
Tested per plan, without the patch I didn't get the sort error, but I did get "result not found"
With the patch, I came back to my same record. I take this as an indicator that the patch is working.
Comment 9 Liz Rea 2013-03-14 08:08:43 UTC
The subject heading I had added was 

Customer Relations (nonsense)

in a 650a
Comment 10 Marcel de Rooy 2013-04-12 07:13:06 UTC
QA: Looking at this one now.
Comment 11 Marcel de Rooy 2013-04-12 08:05:25 UTC
QA Comment:
This is marked trivial, but it appears to be not that trival at all :) Patch complexity is not about the size only..

Liz: If you tested a 650, did you check if it was no an:xxx-link? I tested with 653s for that reason.

The behavior of this patch depends on several pref values, including UseICU and TraceSubjectSubdivisions, and OPAC XSLT.

When the tracing quotes {|} are disabled, the normal quotes are doubled in the XSLT searches leading to the famous: Can't call method "sort" on an undefined value at /usr/share/koha/testclone/C4/Search.pm line 422. 
Note that before the patch, this search would have worked!

Also I feel that this report should also include the search at staff side. A similar change should be made in intranet xslt and normal view to be consistent. Note that now the search in previous example works under staff with two quotes and does not work in opac with four quotes..

Failed QA
Comment 12 Liz Rea 2013-05-09 04:30:44 UTC
The search is not broken on the staff side - and it seems that the same thing happens with Author authorities as well as subjects, I discovered today.
Comment 13 Kyle M Hall 2014-01-14 20:35:16 UTC
*** Bug 8783 has been marked as a duplicate of this bug. ***
Comment 14 Katrin Fischer 2015-02-01 22:21:10 UTC
Sorry, I missed this at first glance and created bug 13650, which is a different approach to fixing this that seems to avoid the problems Marcel found nicely. I tested with different variations of TraceCompleteSubfields and TraceSubjectSubdivisions and didn't find any problems. 

Marking this duplicate.

*** This bug has been marked as a duplicate of bug 13650 ***