To recreate in ktd or sandboxes: 1. In the Koha OPAC go to Advanced search and choose "More options". 2. Do a keyword search for "Doctor Who" with an operator of "Not" and a second keyword search of "video". Only 1 search result shows up. 3. Go back to the advanced search using the back arrow (don't click on Advanced search again). 4. Now search for "Doctor Who" with an operator of "And" and a second keyword search of "video". This shows 3 results. 5. Go back again to advanced search using the back arrow. 6. Try the "Not" video search again. The results show the 3 video results that appeared with the "And" operator. They do not show the 1 result that showed with the "Not" operator.
ALL OPAC advanced search operators are functioning as AND. 1. Do a basic search with two KW terms using OR 2. Repeat the basic search using AND 2. Do an advanced search with same terms in 2 fields using OR Note advanced OR search gives same number of results as AND
The search query varies according to the browser used. For Chrome (anonymous) and Firefox the result URL is correct. For Chrome standard it is not: Started happening in 22.11, when this code in opac-advsearch.tt was introduced: window.addEventListener('pageshow', function( e ){ $('.form-control').prop('disabled' , false ); }); Result URL in Chrome https://catalog.bywatersolutions.com/cgi-bin/koha/opac-search.pl?advsearch=1&op=AND&idx=kw&q=keyword1&op=NOT&idx=kw&q=keyword2&do=Search&sort_by=relevance Result URL in Firefox and anonymous Chrome: https://catalog.bywatersolutions.com/cgi-bin/koha/opac-search.pl?advsearch=1&idx=kw&q=keyword1&op=NOT&idx=kw&q=keyword2&do=Search&sort_by=relevance
It's not good at all :-)
The culprit is bug 33233. It should be reverted or amended.
No back browser button involved in my proof of concept. Our programmer suggests it is a race condition on two different javascript codes.
The change on bug 33233 was quite small, any idea on how we could fix? @@ -459,6 +459,9 @@ [% BLOCK jsinclude %] [% Asset.js("lib/jquery/plugins/jquery.deserialize.min.js") | $raw %] <script> +window.addEventListener('pageshow', function( e ){ + $('.form-control').prop('disabled' , false ); +}); $(document).ready(function() { [% IF search_groups %] function branch_limit() { @@ -559,6 +562,5 @@ $(document).ready(function() { $(this).parent().parent().remove(); $('.search-term-row .search-term-input select[name="op"]').first().prop("disabled",true).hide(); }); - </script> [% END %]
*** Bug 35214 has been marked as a duplicate of this bug. ***
Just found this problem today. On advanced search, keyword OR keyword works fine. subject OR subject is run as subject AND subject (see the URL after running the search). I can manually replace the AND with OR in the url and press enter and the search is run as expected. Just can't do it with the dropdown on the previous page.
I happened to notice the following difference: Firefox: >> $('.form-control').get(0).disabled <- true Chrome: >> $('.form-control').get(0).disabled <- false If you run >> $('.form-control').get(0).disabled = true in the console in chrome the search will work. It looks like this is a hidden <select> which is used for copying the operator dropdown menu when adding additional search clauses. It should be disabled. The difference between browser is probably in execution order. So, a fix is to change the code from bug 33233 to: window.addEventListener('pageshow', function( e ){ $('.form-control:visible').prop('disabled' , false ); });
Created attachment 158598 [details] [review] Bug 34857 Do not enable hidden select element (regression from bug 33233). Test plan: Using Chrome as web browser: * Go to opac advanced search * Press "more options" * Search for two keywords using "and" operator (on ktd search for idea AND behind, which matches 1 result) * Search for two keywords using "or" operator (on ktd search for idea OR behind, which matches 4 results) * Search for two keywords using "not" operator (on ktd search for idea NOT behind, which matches 2 results)
Created attachment 158619 [details] [review] Bug 34857 Do not enable hidden select element (regression from bug 33233). Test plan: Using Chrome as web browser: * Go to opac advanced search * Press "more options" * Search for two keywords using "and" operator (on ktd search for idea AND behind, which matches 1 result) * Search for two keywords using "or" operator (on ktd search for idea OR behind, which matches 4 results) * Search for two keywords using "not" operator (on ktd search for idea NOT behind, which matches 2 results) Signed-off-by: David Nind <david@davidnind.com>
Created attachment 158621 [details] [review] Bug 34857 Do not enable hidden select element (regression from bug 33233). Test plan: Using Chrome as web browser: * Go to opac advanced search * Press "more options" * Search for two keywords using "and" operator (on ktd search for idea AND behind, which matches 1 result) * Search for two keywords using "or" operator (on ktd search for idea OR behind, which matches 4 results) * Search for two keywords using "not" operator (on ktd search for idea NOT behind, which matches 2 results) Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Thanks a lot Andreas, I am really happy to see this one fixed.
QA: the commit title fails the qa script tests.
Pushed to master for 23.11. Nice work everyone, thanks!
I am sorry, I thought I had fixed that.
The title of this bug is misleading. It is not limited to Chrome. I can reproduce in Firefox.
(In reply to Christopher Brannon from comment #17) > The title of this bug is misleading. It is not limited to Chrome. I can > reproduce in Firefox. I tested using Firefox Developer Edition (Firefox version 120.0b7) and Chromium (version 119.0.6045.105) (on Ubuntu 22.04) - I was not able to replicate the problem in Firefox. As far as I could see, it was specific to Chrome-based browsers. I'll have another go shortly and see if I can replicate the issue using Firefox.
Pushed to 23.05.x for 23.05.06
Nice work everyone! Pushed to 22.11.x for next release
(In reply to Pedro Amorim from comment #20) > Nice work everyone! > > Pushed to 22.11.x for next release Nice! Thank you!