Bug 16976

Summary: Authorities searches with double quotes gives ZOOM error 20003
Product: Koha Reporter: Miguel Tuimil <miguel.tuimil>
Component: SearchingAssignee: Nick Clemens <nick>
Status: RESOLVED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: critical    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, katrin.fischer, m.de.rooy, mtj, nick, tomascohen, veron
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18689
Whiteboard:
Change sponsored?: --- Patch complexity: Trivial patch
Bot Control: --- When did the bot last check this:
Who signed the patch off: Text to go in the release notes:
Bug Depends on: 10407    
Bug Blocks:    
Attachments: Bug 16976: Authorities searches with double quotes gives ZOOM error 20003
Bug 16976: Authorities searches with double quotes gives ZOOM error 20003
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]
Bug 16976 - Unit tests
Bug 16976 - Unit tests
Bug 16976 - Unit tests
Bug 16976 - Unit tests
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]
Bug 16976 - Unit tests
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]
Bug 16976 - Unit tests
[SIGNED OFF] Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]
[SIGNED OFF] Bug 16976 - Unit tests

Description Miguel Tuimil 2016-07-26 09:04:07 UTC
Any search on authorities(authorities/authorities-home.pl) that includes double quotes, for example "Enrico Fermi" gives:

Software error:

ZOOM error 20003 "can't set prefix query" (addinfo: "@or @attr 7=1 @attr 1=Heading 0  @attr 1=Heading-Main  @attr 5=1 @attr 4=6 "\\"Enrico Fermi\\""") from diag-set 'ZOOM'
Comment 1 Marc Véron 2017-05-29 05:30:30 UTC
Confirmed on current master.
Steps to reproduce:

Go to Home > Authorities
Search "test" (including double quotes

Result: Internal server error, plack error log says:
ZOOM error 20003 "can't set prefix query" (addinfo: "@or @attr 7=1 @attr 1=Heading 0  @attr 1=Heading-Main  @attr 5=1 @attr 4=6 "\\"test\\""") from diag-set 'ZOOM'

Same with search after "test (one qoute only
Comment 2 Marc Véron 2017-06-05 07:15:48 UTC
Created attachment 63957 [details] [review]
Bug 16976: Authorities searches with double quotes gives ZOOM error 20003

To recreate:
Go to Home > Authorities
Search "test" (including double quotes

Result: Internal server error, plack error log says:
ZOOM error 20003 "can't set prefix query" (addinfo: "@or @attr 7=1 @attr 1=Heading 0  @attr 1=Heading-Main  @attr 5=1 @attr 4=6 "\\"test\\""") from diag-set 'ZOOM'

To test:
- Appply patch, restart memchached an dplack
- Repeat search "test"
- Verify that there is no internal server error
- Add an authority containing quotes, e.g. Johann "Wolfie" Goethe
- Search after Wolfie (without quotes)
- Verify that authority ist found
- Search after "Wolfie"
- Verify that authority is found
- Verify that other searches for authorities behave as before

Technical note: Escaping did not work. The patch simply removes double
quotes from search values. Not sure if that is the ultimate solution, but
it works.
Comment 3 Lee Jamison 2017-06-05 14:54:18 UTC
Created attachment 63963 [details] [review]
Bug 16976: Authorities searches with double quotes gives ZOOM error 20003

To recreate:
Go to Home > Authorities
Search "test" (including double quotes

Result: Internal server error, plack error log says:
ZOOM error 20003 "can't set prefix query" (addinfo: "@or @attr 7=1 @attr 1=Heading 0  @attr 1=Heading-Main  @attr 5=1 @attr 4=6 "\\"test\\""") from diag-set 'ZOOM'

To test:
- Appply patch, restart memchached an dplack
- Repeat search "test"
- Verify that there is no internal server error
- Add an authority containing quotes, e.g. Johann "Wolfie" Goethe
- Search after Wolfie (without quotes)
- Verify that authority ist found
- Search after "Wolfie"
- Verify that authority is found
- Verify that other searches for authorities behave as before

Technical note: Escaping did not work. The patch simply removes double
quotes from search values. Not sure if that is the ultimate solution, but
it works.

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Comment 4 Nick Clemens 2017-06-16 10:54:06 UTC
Created attachment 64382 [details] [review]
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]

I dug into this a little bit, it seems the issue is that we were double
processing the query because of an extra call to
C4::AuthoritiesMarc::SearchAuthorities

I think we can simply remove this call

To test:
1 - Perform an authority search for a value that returns results
2 - Wrap it in quotes and search
3 - 'Internal server error'
4 - Apply patch
5 - Search with quotes succeeds

https://bugs.koha-community.org/show_bug.cgi?id=16796
Comment 5 Lee Jamison 2017-06-16 13:36:40 UTC
Created attachment 64384 [details] [review]
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]

I dug into this a little bit, it seems the issue is that we were double
processing the query because of an extra call to
C4::AuthoritiesMarc::SearchAuthorities

I think we can simply remove this call

To test:
1 - Perform an authority search for a value that returns results
2 - Wrap it in quotes and search
3 - 'Internal server error'
4 - Apply patch
5 - Search with quotes succeeds

https://bugs.koha-community.org/show_bug.cgi?id=16796

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
When testing in kohadevbox a restart_all is required
Comment 6 Tomás Cohen Arazi 2017-06-26 15:18:46 UTC
Created attachment 64655 [details] [review]
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]

I dug into this a little bit, it seems the issue is that we were double
processing the query because of an extra call to
C4::AuthoritiesMarc::SearchAuthorities

I think we can simply remove this call

To test:
1 - Perform an authority search for a value that returns results
2 - Wrap it in quotes and search
3 - 'Internal server error'
4 - Apply patch
5 - Search with quotes succeeds

https://bugs.koha-community.org/show_bug.cgi?id=16796

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 7 Jonathan Druart 2017-07-06 16:42:59 UTC
Please provide tests.
Comment 8 Nick Clemens 2017-07-07 17:58:32 UTC Comment hidden (obsolete)
Comment 9 Nick Clemens 2017-07-11 14:01:05 UTC Comment hidden (obsolete)
Comment 10 Nick Clemens 2017-07-11 14:03:55 UTC
Created attachment 64999 [details] [review]
Bug 16976 - Unit tests
Comment 11 Marcel de Rooy 2017-07-14 06:48:03 UTC
Applying: Bug 16976 - Unit tests
fatal: sha1 information is lacking or useless (t/Search/Zebra/QueryBuilder.t).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Comment 12 Tomás Cohen Arazi 2017-08-08 13:25:33 UTC
(In reply to Nick Clemens from comment #10)
> Created attachment 64999 [details] [review] [review]
> Bug 16976 - Unit tests

Nick, please comment on which bug this one depends (for the tests)
Comment 13 Nick Clemens 2017-08-11 12:11:55 UTC
Created attachment 65901 [details] [review]
Bug 16976 - Unit tests
Comment 14 Nick Clemens 2017-08-11 12:12:48 UTC
(In reply to Tomás Cohen Arazi from comment #12)
> Nick, please comment on which bug this one depends (for the tests)

Ah, sorry about that - accidentally obsoleted an extra patch, this depended on itself :-)
Comment 15 Marcel de Rooy 2017-08-11 12:56:30 UTC
Created attachment 65902 [details] [review]
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]

I dug into this a little bit, it seems the issue is that we were double
processing the query because of an extra call to
C4::AuthoritiesMarc::SearchAuthorities

I think we can simply remove this call

To test:
1 - Perform an authority search for a value that returns results
2 - Wrap it in quotes and search
3 - 'Internal server error'
4 - Apply patch
5 - Search with quotes succeeds

https://bugs.koha-community.org/show_bug.cgi?id=16796

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 16 Marcel de Rooy 2017-08-11 12:56:34 UTC
Created attachment 65903 [details] [review]
Bug 16976 - Unit tests
Comment 17 Marcel de Rooy 2017-08-11 12:57:26 UTC
Created attachment 65904 [details] [review]
Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]

I dug into this a little bit, it seems the issue is that we were double
processing the query because of an extra call to
C4::AuthoritiesMarc::SearchAuthorities

I think we can simply remove this call

To test:
1 - Perform an authority search for a value that returns results
2 - Wrap it in quotes and search
3 - 'Internal server error'
4 - Apply patch
5 - Search with quotes succeeds

https://bugs.koha-community.org/show_bug.cgi?id=16796

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 18 Marcel de Rooy 2017-08-11 12:57:30 UTC
Created attachment 65905 [details] [review]
Bug 16976 - Unit tests

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 19 Katrin Fischer 2017-08-15 14:59:05 UTC
Created attachment 66017 [details] [review]
[SIGNED OFF] Bug 16976 - Authorities searches with double quotes gives ZOOM error 20003 [Alternate]

I dug into this a little bit, it seems the issue is that we were double
processing the query because of an extra call to
C4::AuthoritiesMarc::SearchAuthorities

I think we can simply remove this call

To test:
1 - Perform an authority search for a value that returns results
2 - Wrap it in quotes and search
3 - 'Internal server error'
4 - Apply patch
5 - Search with quotes succeeds

https://bugs.koha-community.org/show_bug.cgi?id=16796

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 20 Katrin Fischer 2017-08-15 15:00:14 UTC
Created attachment 66018 [details] [review]
[SIGNED OFF] Bug 16976 - Unit tests

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 21 Jonathan Druart 2017-08-15 15:26:20 UTC
Pushed to master for 17.11, thanks to everybody involved!
Comment 22 Fridolin SOMERS 2017-09-06 13:18:21 UTC
Pushed to 17.05.x, will be in 17.05.04
Comment 23 Katrin Fischer 2017-09-10 08:36:34 UTC
These patches have been pushed to 16.11.x and will be in 16.11.12.
Comment 24 Mason James 2017-09-19 23:59:24 UTC
Blocked by Enhancement (10407), skipping for 16.05.x

FYI: I've confirmed that 16.05.x is not affected by this bug :0)