To recreate: - go to adv search on the OPAC - check a limiter box under CCODE, LOC, or ITYPE - do not enter any search terms - click search, get results - use the Sort dropdown to change the sort - Koha kicks you back to the search page
We're using some dropdown lists of search options based on shelving location codes that patrons can use to easily get to new items. <h1>Just Arrived</h1> <p><form name="searchform" method="get" action="/cgi-bin/koha/opac-search.pl"> <input name="idx" value="kw" type="hidden"> <input name="sort_by" value="acqdate_dsc" type="hidden"> <input name="do" value="OK" type="hidden"> <select name="limit" onchange="this.form.submit()"> <option>-- Please choose --</option> <option value="mc-loc:FN">New Fiction</option> <option value="mc-loc:FMN">New Mystery</option> <option value="mc-loc:FYAN">New YA Fiction</option> </select> </form> </p> We also use some jQuery for an item type limiter that can be used when searching. //BEGIN Add Search Limits to Main Search Box opac-main.pl $(".mastheadsearch #masthead_search").after(" <select name='limit' id='item_type_dropdown'><option value=''>All Items</option><option id='book_limit' value='mc-itype,phr:BOOK'>Books</option><option id='dvdmovie_limit' value='mc-itype,phr:DVDMOVIE'>DVDs (Movies & TV)</option><option id='dvdnf_limit' value='mc-itype,phr:DVDNF'>DVDs (Non-Fiction)</option></select>"); Because the code doesn't have search terms in it the list of results can't be sorted. We could change everything to use direct urls but that takes a lot of time. Being able to use locations and item types in the code is easier and cleaner.
Created attachment 108176 [details] [review] Bug 25872: Unit tests
Created attachment 108177 [details] [review] Bug 25872: Fix scoping of $limits To test: 1 - Enable Elasticsearch 2 - On OPAC perform advanced search, selecting only an itype, ccode, or LOC limit 3 - Attempt to sort results 4 - You are returned to Advanced search 5 - Apply patch 6 - Repeat 7 - It sorts!
Created attachment 108211 [details] [review] Bug 25872: Unit tests Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com>
Created attachment 108212 [details] [review] Bug 25872: Fix scoping of $limits To test: 1 - Enable Elasticsearch 2 - On OPAC perform advanced search, selecting only an itype, ccode, or LOC limit 3 - Attempt to sort results 4 - You are returned to Advanced search 5 - Apply patch 6 - Repeat 7 - It sorts! Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com>
Worked great!
Created attachment 108257 [details] [review] Bug 25872: Unit tests Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Created attachment 108258 [details] [review] Bug 25872: Fix scoping of $limits To test: 1 - Enable Elasticsearch 2 - On OPAC perform advanced search, selecting only an itype, ccode, or LOC limit 3 - Attempt to sort results 4 - You are returned to Advanced search 5 - Apply patch 6 - Repeat 7 - It sorts! Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Please remember to include a short description of the fix (what was wrong?) in your commit message as well.
Created attachment 108507 [details] [review] Bug 25872: Fix scoping of $limits The code in build_query_compat contained a 'my' in the assigning of limits for the search in a conditional This meant the limits were being set correctly during the conditional, but we blanked when passed to the rest of the code. The effect was that the searches worked, however, the template params to repeat the search were incomplete. Removing the my ensures the same limits are applied during search and on re-sorting To test: 1 - Enable Elasticsearch 2 - On OPAC perform advanced search, selecting only an itype, ccode, or LOC limit 3 - Attempt to sort results 4 - You are returned to Advanced search 5 - Apply patch 6 - Repeat 7 - It sorts! Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Pushed to master for 20.11, thanks to everybody involved!
backported to 20.05.x for 20.05.03
couldn't reproduce on 19.11.x. not backported