Bug 31543

Summary: MaxComponentRecords link is broken
Product: Koha Reporter: Caroline Cyr La Rose <caroline.cyr-la-rose>
Component: SearchingAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: claes.eriksson, david, nick, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11
Circulation function:
Bug Depends on: 11175    
Bug Blocks:    
Attachments: Example marc file
Bug 31543: Use query string, rather than query, to build link
Bug 31543: (follow-up) Use url filter for opac components search
Bug 31543: Use query string, rather than query, to build link
Bug 31543: (follow-up) Use url filter for opac components search
Bug 31543: Use query string, rather than query, to build link
Bug 31543: (follow-up) Use url filter for opac components search

Description Caroline Cyr La Rose 2022-09-09 21:47:21 UTC
I was trying out the Component records feature and noticed the link when you have more component records than MaxComponentRecords is broken.

I'm using Elasticsearch, if that changes anything.

1)Import the example file 

1.1) Go to Tools > Stage MARC records for import
1.2) Upload the example file
1.3) In the form, choose the format 'MARCXML'
1.4) Click 'Stage for import'
1.5) Click 'Manage staged records'
1.6) Click 'Import this batch into the catalog'

2) Change MaxComponentRecords to 10
3) In the staff interface, search the catalog for 'easy piano'
4) Click on the record 'Easy piano pieces for children'
5) Click on the 'show all component parts' link at the bottom of the Components tab
--> it searches for HASH(...) - returns no results
6) Try the same in OPAC
--> it searches for HASH(...) - returns no results
Comment 1 Caroline Cyr La Rose 2022-09-09 21:48:10 UTC
Created attachment 140384 [details]
Example marc file

I stole the example marc file from bug 11175
Comment 2 Caroline Cyr La Rose 2022-09-09 21:50:15 UTC
Oops, I forgot to say that you have to enable the ShowComponentRecords syspref too.

1)Import the example file 

1.1) Go to Tools > Stage MARC records for import
1.2) Upload the example file
1.3) In the form, choose the format 'MARCXML'
1.4) Click 'Stage for import'
1.5) Click 'Manage staged records'
1.6) Click 'Import this batch into the catalog'

2) Change ShowComponentRecords to 'both staff interface and OPAC'
3) Change MaxComponentRecords to 10
4) In the staff interface, search the catalog for 'easy piano'
5) Click on the record 'Easy piano pieces for children'
6) Click on the 'show all component parts' link at the bottom of the Components tab
--> it searches for HASH(...) - returns no results
7) Try the same in OPAC
--> it searches for HASH(...) - returns no results
Comment 3 Nick Clemens (kidclamp) 2022-10-26 10:50:46 UTC
Created attachment 142665 [details] [review]
Bug 31543: Use query string, rather than query, to build link

This patch returns the query string from build_query_compat
Under Zebra, either works for the link, for ES we need the simple string

I expand the test for get_components_query to test both engines

To test:
1.0) Set search engine to Elasticsearch
1.1) Go to Tools > Stage MARC records for import
1.2) Upload the example file
1.3) In the form, choose the format 'MARCXML'
1.4) Click 'Stage for import'
1.5) Click 'Manage staged records'
1.6) Click 'Import this batch into the catalog'

2) Change MaxComponentRecords to 10
3) In the staff interface, search the catalog for 'easy piano'
4) Click on the record 'Easy piano pieces for children'
5) Click on the 'show all component parts' link at the bottom of the Components tab
--> it searches for HASH(...) - returns no results
6) Try the same in OPAC
--> it searches for HASH(...) - returns no results
7) Apply patch and restart all
8) repeat 3-6
9) Results returned!
Comment 4 David Nind 2022-11-07 20:07:25 UTC
This works on the staff interface, but I get no results for the OPAC.

This is related to the query in the URL I think.

OPAC:
- Query in URL generated on the OPAC: /cgi-bin/koha/opac-search.pl?q=Host-item%3A("Easy piano pieces for children \%2F")%26sort_by%3Dtitle_asc
- Search box: Host-item:("Easy piano pieces for children \/")&sort_by=title_asc
- Note - the staff interface has this in the search box: Host-item:("Easy piano pieces for children \/")

If I change the query in the OPAC URL to the match that used in the staff interface, it works:
- Change OPAC URL to: /cgi-bin/koha/opac-search.pl?q=Host-item:("Easy piano pieces for children \/")&sort_by=title_asc
- OPAC search box: Host-item:("Easy piano pieces for children \/")
Comment 5 Nick Clemens (kidclamp) 2022-11-16 11:03:57 UTC
Created attachment 143948 [details] [review]
Bug 31543: (follow-up) Use url filter for opac components search

The previous patch switches to using 'query_string' which is returned encoded.
Using uri we doulbe encode the string - this patch prevents that
Comment 6 David Nind 2022-11-16 17:18:54 UTC
Created attachment 143963 [details] [review]
Bug 31543: Use query string, rather than query, to build link

This patch returns the query string from build_query_compat
Under Zebra, either works for the link, for ES we need the simple string

I expand the test for get_components_query to test both engines

To test:
1.0) Set search engine to Elasticsearch
1.1) Go to Tools > Stage MARC records for import
1.2) Upload the example file
1.3) In the form, choose the format 'MARCXML'
1.4) Click 'Stage for import'
1.5) Click 'Manage staged records'
1.6) Click 'Import this batch into the catalog'

2) Change MaxComponentRecords to 10
3) In the staff interface, search the catalog for 'easy piano'
4) Click on the record 'Easy piano pieces for children'
5) Click on the 'show all component parts' link at the bottom of the Components tab
--> it searches for HASH(...) - returns no results
6) Try the same in OPAC
--> it searches for HASH(...) - returns no results
7) Apply patch and restart all
8) repeat 3-6
9) Results returned!

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2022-11-16 17:18:58 UTC
Created attachment 143964 [details] [review]
Bug 31543: (follow-up) Use url filter for opac components search

The previous patch switches to using 'query_string' which is returned encoded.
Using uri we doulbe encode the string - this patch prevents that

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 Katrin Fischer 2022-11-16 18:26:50 UTC
Created attachment 143965 [details] [review]
Bug 31543: Use query string, rather than query, to build link

This patch returns the query string from build_query_compat
Under Zebra, either works for the link, for ES we need the simple string

I expand the test for get_components_query to test both engines

To test:
1.0) Set search engine to Elasticsearch
1.1) Go to Tools > Stage MARC records for import
1.2) Upload the example file
1.3) In the form, choose the format 'MARCXML'
1.4) Click 'Stage for import'
1.5) Click 'Manage staged records'
1.6) Click 'Import this batch into the catalog'

2) Change MaxComponentRecords to 10
3) In the staff interface, search the catalog for 'easy piano'
4) Click on the record 'Easy piano pieces for children'
5) Click on the 'show all component parts' link at the bottom of the Components tab
--> it searches for HASH(...) - returns no results
6) Try the same in OPAC
--> it searches for HASH(...) - returns no results
7) Apply patch and restart all
8) repeat 3-6
9) Results returned!

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 9 Katrin Fischer 2022-11-16 18:26:54 UTC
Created attachment 143966 [details] [review]
Bug 31543: (follow-up) Use url filter for opac components search

The previous patch switches to using 'query_string' which is returned encoded.
Using uri we doulbe encode the string - this patch prevents that

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 10 Tomás Cohen Arazi (tcohen) 2022-11-16 19:04:42 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!