Bug 36563

Summary: Item search does not search for multiple values
Product: Koha Reporter: Michaela Sieber <michaela.sieber>
Component: SearchingAssignee: Pedro Amorim <pedro.amorim>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: aleisha, blawlor, clemens.tubach, fridolin.somers, lucas, michael.skarupianski, mspinney, pedro.amorim, sspohn, 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:
24.05.00,23.11.06,23.05.12
Circulation function:
Bug Depends on: 34913    
Bug Blocks: 36930, 36545    
Attachments: Bug 36563: Dirty fix
Bug 36563: Dirty fix
Bug 36563: Turn into array only if required
Bug 36563: Dirty fix
Bug 36563: Turn into array only if required
Bug 36563: Turn into array only if required
Bug 36563: Turn into array only if required
Bug 36563: Turn into array only if required
Bug 36563: Turn into array only if required

Description Michaela Sieber 2024-04-10 07:52:43 UTC
To recreate in Master :

- go to item search 
- select at least two home libraries (e.g. Centerville + Midway)
- check that the search results will only show the results of the second selected library
Comment 1 Jonathan Druart 2024-04-10 10:04:37 UTC
Created attachment 164595 [details] [review]
Bug 36563: Dirty fix
Comment 2 Lucas Gass (lukeg) 2024-04-10 10:09:17 UTC
Created attachment 164596 [details] [review]
Bug 36563: Dirty fix

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 3 Lucas Gass (lukeg) 2024-04-10 11:22:13 UTC
'is not' searches dont appear to be working either
Comment 4 Katrin Fischer 2024-04-10 12:31:10 UTC
(In reply to Lucas Gass from comment #3)
> 'is not' searches dont appear to be working either

Should we fix that here or separately?
Comment 5 Lucas Gass (lukeg) 2024-04-11 07:53:38 UTC
(In reply to Katrin Fischer from comment #4)
> (In reply to Lucas Gass from comment #3)
> > 'is not' searches dont appear to be working either
> 
> Should we fix that here or separately?

I filed Bug 36571
Comment 6 Pedro Amorim 2024-04-11 10:50:45 UTC
Created attachment 164673 [details] [review]
Bug 36563: Turn into array only if required

Test plan, apply first patch:
1- Visit item search:
http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl
2- Set "Home library" -> "is not" -> "Centerville". Notice you get items from Centerville.
3- Apply second patch, repeat step 2, notice you now don't get items from Centervile.
Comment 7 Pedro Amorim 2024-04-11 11:57:16 UTC
Created attachment 164675 [details] [review]
Bug 36563: Dirty fix

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 8 Pedro Amorim 2024-04-11 11:57:19 UTC
Created attachment 164676 [details] [review]
Bug 36563: Turn into array only if required

Test plan, apply first patch:
1- Visit item search:
http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl
2- Set "Home library" -> "is not" -> "Centerville". Notice you get items from Centerville.
3- Apply second patch, repeat step 2, notice you now don't get items from Centervile.

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 9 Lucas Gass (lukeg) 2024-04-11 11:57:40 UTC
Created attachment 164677 [details] [review]
Bug 36563: Turn into array only if required

Test plan, apply first patch:
1- Visit item search:
http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl
2- Set "Home library" -> "is not" -> "Centerville". Notice you get items from Centerville.
3- Apply second patch, repeat step 2, notice you now don't get items from Centervile.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 10 Lucas Gass (lukeg) 2024-04-11 13:14:28 UTC
This now only works if you are selecting multiple parameters. If you choose only 1 the search doesn't work.
Comment 11 Pedro Amorim 2024-04-11 14:31:07 UTC
Created attachment 164756 [details] [review]
Bug 36563: Turn into array only if required

Test plan, apply first patch:
1- Visit item search:
http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl
2- Set "Home library" -> "is not" -> "Centerville". Notice you get items from Centerville.
3- Apply second patch, repeat step 2, notice you now don't get items from Centervile.
4- Test other use cases, like 'is' and 'is not' for multiple choices
Comment 12 Pedro Amorim 2024-04-11 14:32:19 UTC
(In reply to Lucas Gass from comment #10)
> This now only works if you are selecting multiple parameters. If you choose
> only 1 the search doesn't work.

Thank you Lucas, I've resubmitted a new version of the patch. Can you please try and test again? Thanks!
Comment 13 Pedro Amorim 2024-04-11 14:40:34 UTC
I tried something more pretty like:
my @q = $cgi->param( $p . "[]" ) // $cgi->param( $p );

But I failed. For some reason that doesn't work.
Comment 14 Owen Leonard 2024-04-12 15:57:16 UTC
Created attachment 164857 [details] [review]
Bug 36563: Turn into array only if required

Test plan, apply first patch:
1- Visit item search:
   http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl
2- Set "Home library" -> "is not" -> "Centerville". Notice you get items
   from Centerville.
3- Apply second patch, repeat step 2, notice you now don't get items
   from Centervile.
4- Test other use cases, like 'is' and 'is not' for multiple choices

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 15 Lucas Gass (lukeg) 2024-04-18 17:49:01 UTC
Thanks Pedro. This seems to be working well now with is/is not operators. Scripts are happy, passing QA.
Comment 16 Lucas Gass (lukeg) 2024-04-18 17:49:41 UTC
Created attachment 165141 [details] [review]
Bug 36563: Turn into array only if required

Test plan, apply first patch:
1- Visit item search:
   http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl
2- Set "Home library" -> "is not" -> "Centerville". Notice you get items
   from Centerville.
3- Apply second patch, repeat step 2, notice you now don't get items
   from Centervile.
4- Test other use cases, like 'is' and 'is not' for multiple choices

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 17 Katrin Fischer 2024-04-19 15:11:51 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 18 Aleisha Amohia 2024-04-24 00:34:38 UTC
Noting I see the keywords already to get this into 23.11 and 23.05 ... and we will be very happy about it :)
Comment 19 Michelle Spinney 2024-05-10 13:51:43 UTC
+Aleisha -- we use this daily for database maintenance
Comment 20 Michaela Sieber 2024-05-16 07:41:08 UTC
Could this please be backported ?
Comment 21 Fridolin Somers 2024-05-22 12:36:00 UTC
Pushed to 23.11.x for 23.11.06
Comment 22 Lucas Gass (lukeg) 2024-05-23 14:06:20 UTC
Backported to 23.05.x for upcoming 23.05.12