In the Item search a librarian is allowed, in the first step, to define additional filters like Title, Author, Publisher, Publication date etc. (the third fieldset). This works fine but only for one criterion. If one adds two or more criteria, the filter does not apply at all.
Created attachment 167052 [details] [review] Bug 36930: Item search gives irrelevant results when using 2+ added filter criteria In the Item search the librarian is allowed, in the first step, to define additional filters like Title, Author, Publisher, Publication date etc. (in the third fieldset). This works fine but only for one criterion. If one adds two or more criteria, the filter does not apply at all. Test plan ========= 1. Make an Item search with the Pulblisher filter. Put %University of California% as the value. You should get 5 rows (with standard ktd test data set), three from 1982, and two from 1988. 2. Edit search -> add the second criterion: AND Publication date is 1982. You would expect three rows but you get 900+ rows. 3. Apply the patch; restart_all. 4. Repeat p. 2. You should get the expected three rows.
BTW, I have no idea why the CGI parameters change their names from q into q[], f into f[], etc., depending on the number of the rows in the form--but they do. Certainly there is an explanation--any hint would be appreciated.
This is needed in addition to bug 36563?
(In reply to Katrin Fischer from comment #3) > This is needed in addition to bug 36563? Oh, that's strange indeed. The bug description seems similar. To be sincere, I didn't see it prior to submitting my patch, but I worked on fresh main of yesterday. So, it seems to be still a problem. The bug 36563 would work only for the two first fieldsetd, if I guess right. And the mine--for the third.
Hey, I intend to take a look here when possible but adding other possibly interested parties to the mix in the meantime.
(In reply to Janusz Kaczmarek from comment #2) > Certainly there is an explanation--any hint would be appreciated. This patch (I believe a follow-up to the datatables upgrade from 1.10.18 to 1.13.6): https://github.com/Koha-Community/Koha/commit/63183059dd975c2f5265fa4c7d2bc59b6ad1a252#diff-20d8383af8b7699632bc26d50203158fc58acbfad77efdbe6134017a1a1d1ec7R482 (link goes directly to the line we're addressing here) This changed the payload data from an array of JSON objects to a single JSON object. This caused a problem, because a JSON object can only have one instance of a property and this scenario was not considered for more than 1 arg for the same filter. Using Janusz's use-case, this is what the request payload looked like: [ ..., {name: 'f', value: 'publishercode'}, {name: 'op', value: 'like'}, {name: 'q', value: '%University of California%'}, {name: 'c', value: 'and'}, {name: 'f', value: 'publicationyear'}, {name: 'op', value: 'like'}, {name: 'q', value: '1988'}, ... ] But after that patch, this is what we had (same use-case - notice the absence of the first query parameters set): { ... c: 'and', f: 'publicationyear', op: 'like', q: '1988', ... } This is because the following line: d[params[i].name] = params[i].value; Was effectivelly doing: d['f'] = 'publishercode'; d['f'] = 'publicationyear'; The end result is you only get the last property value in the final object. You can test this yourself: Rest your branch to the commit directly before the datatables upgrade: git reset --hard b54da05c73c9ea5b04d3552b34fcc636b0a71851 reset_all And console.log(aoData) in itemsearch.tt Then, reset your branch to the commit directly before bug 36563: git reset --hard 903a8685c661ddde61335a08e126506120345abc reset_all And console.log(d) after the for loop
Created attachment 167169 [details] [review] Bug 36930: Item search gives irrelevant results when using 2+ added filter criteria In the Item search the librarian is allowed, in the first step, to define additional filters like Title, Author, Publisher, Publication date etc. (in the third fieldset). This works fine but only for one criterion. If one adds two or more criteria, the filter does not apply at all. Test plan ========= 1. Make an Item search with the Pulblisher filter. Put %University of California% as the value. You should get 5 rows (with standard ktd test data set), three from 1982, and two from 1988. 2. Edit search -> add the second criterion: AND Publication date is 1982. You would expect three rows but you get 900+ rows. 3. Apply the patch; restart_all. 4. Repeat p. 2. You should get the expected three rows. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
I think the patch is good, it's basically a follow-up of bug 36563 as it's addressing use cases we missed (i.e. forgot to test) at the time.
Works fine, even with +3 filter criteria (one with MARC field 260$a)
Created attachment 167340 [details] [review] Bug 36930: Item search gives irrelevant results when using 2+ added filter criteria In the Item search the librarian is allowed, in the first step, to define additional filters like Title, Author, Publisher, Publication date etc. (in the third fieldset). This works fine but only for one criterion. If one adds two or more criteria, the filter does not apply at all. Test plan ========= 1. Make an Item search with the Pulblisher filter. Put %University of California% as the value. You should get 5 rows (with standard ktd test data set), three from 1982, and two from 1988. 2. Edit search -> add the second criterion: AND Publication date is 1982. You would expect three rows but you get 900+ rows. 3. Apply the patch; restart_all. 4. Repeat p. 2. You should get the expected three rows. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Thanks for the fix here Janusz, and the clear reasoning and testing Pedro. All looking solid to me, Passing QA
Thanks for all the hard work! Pushed to main for the next 24.11.00 release as RM Assistant
Backported to 24.05.x for upcoming 24.05.02
Pushed to 23.11.x for 23.11.07
Backported to 23.05.x for 23.05.15