Bug 33117 - Patron checkout search not working if searching with second surname
Summary: Patron checkout search not working if searching with second surname
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: master
Hardware: All All
: P5 - low normal with 2 votes (vote)
Assignee: Laura Escamilla
QA Contact: Martin Renvoize
URL:
Keywords: additional_work_needed, rel_22_11_candidate, rel_23_05_candidate
Depends on: 32772
Blocks: 35127 34083 34580
  Show dependency treegraph
 
Reported: 2023-03-02 17:18 UTC by Isabel Pineda
Modified: 2024-01-12 16:21 UTC (History)
18 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.02,22.11.09,22.11.08


Attachments
Bug 33117: Added new syspref Patronautocompletesesarchmethod (10.94 KB, patch)
2023-03-09 17:11 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (10.95 KB, patch)
2023-03-09 19:14 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (12.72 KB, patch)
2023-03-10 16:55 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (13.15 KB, patch)
2023-03-13 17:12 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (14.91 KB, patch)
2023-03-13 19:03 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (14.90 KB, patch)
2023-03-16 17:14 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (14.87 KB, patch)
2023-03-16 17:30 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (14.84 KB, patch)
2023-03-16 17:42 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (14.88 KB, patch)
2023-03-16 18:07 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (15.04 KB, patch)
2023-03-17 12:51 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (15.37 KB, patch)
2023-03-17 18:15 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (15.32 KB, patch)
2023-03-17 19:07 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (15.39 KB, patch)
2023-03-21 12:20 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (14.88 KB, patch)
2023-03-21 12:44 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (14.26 KB, patch)
2023-03-21 13:23 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 33117: Added new syspref Patronautocompletesesarchmethod (14.32 KB, patch)
2023-03-21 14:51 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 33117: New System Preference PatronAutoCompleteSearchMethod (4.96 KB, patch)
2023-05-05 17:28 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: New System Preference PatronAutoCompleteSearchMethod (4.96 KB, patch)
2023-05-09 17:25 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: New System Preference PatronAutoCompleteSearchMethod (5.00 KB, patch)
2023-05-09 17:37 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: New System Preference PatronAutoCompleteSearchMethod (5.00 KB, patch)
2023-05-09 18:07 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: New System Preference PatronAutoCompleteSearchMethod (5.99 KB, patch)
2023-05-11 18:04 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Adding new system preference for patron searching (4.46 KB, patch)
2023-05-11 18:43 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Adding new system preference for patron searching (4.46 KB, patch)
2023-05-16 15:11 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Adding new system preference for patron searching (5.44 KB, patch)
2023-05-16 16:12 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Adding new system preference for patron searching (5.43 KB, patch)
2023-05-16 18:53 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference (5.49 KB, patch)
2023-05-26 16:57 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: New system preference - PatronAutoCompleteSearchMethod (5.38 KB, patch)
2023-05-26 21:09 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference (5.58 KB, patch)
2023-05-30 19:52 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference (5.60 KB, patch)
2023-05-30 20:26 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference (6.97 KB, patch)
2023-06-22 11:25 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference (7.00 KB, patch)
2023-06-22 11:26 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: (follow-up) Rename preference (7.51 KB, patch)
2023-06-22 11:41 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: (follow-up) Rename preference (7.49 KB, patch)
2023-06-22 11:48 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: (follow-up) Rename preference (8.22 KB, patch)
2023-06-22 12:01 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: (follow-up) Rename preference (8.22 KB, patch)
2023-06-22 13:36 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference (7.00 KB, patch)
2023-06-22 13:44 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: (follow-up) Rename preference (8.22 KB, patch)
2023-06-22 13:44 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: (follow-up) Make preference options match existing codebase (4.19 KB, patch)
2023-06-22 13:44 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33117: Make dbrev idempotent (1.12 KB, patch)
2023-08-07 18:30 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Isabel Pineda 2023-03-02 17:18:36 UTC
We are running Koha 22.11.03 in Spanish, and today I have found a problem if I search for a patron in the staff interface with the “checkout” search (“préstamo”). 

In Spanish speaking countries, people usually have 2 surnames. When I create a new user, I write both surnames in the “surname” field and both given names in the “First name” field.

If I enter the name or parts of it in the “checkout” search, without hitting Enter, I get a list of results where I can choose from. It used to be possible in previous versions to search for patrons using the first name and the second surname. Today I found that this is not possible anymore. For example, if there is a patron with the name “Carla María Ramírez Hernández”, I find her if I search with “Carla Ramírez”, but not if I search with “Carla Hernández”. It doesn´t work either if I search with the second given name and first surname (“María Ramírez”).
Comment 1 Jonathan Druart 2023-03-07 09:50:04 UTC
Regression caused by bug 32772.
Comment 2 Nick Clemens 2023-03-07 12:09:23 UTC
(In reply to Jonathan Druart from comment #1)
> Regression caused by bug 32772.

The previous behvaiour is still possible, it now requires entering a wildcard before your term, e.g.:
%María %Ramírez

It's a trade off, some libraries were getting too many results, now some are getting too few. We went towards a default of 'starts with' because it allowed wildcard use to replicate previous behvaiour

I would support a switch (syspref) to allow choosing 'starts with' or 'contains' as the default for patron searching.
Comment 3 Isabel Pineda 2023-03-07 13:00:29 UTC
> I would support a switch (syspref) to allow choosing 'starts with' or 'contains' as the default for patron searching.


I would like to support this too. In our library we are dealing very often with little children who don't know all of their first and last names, which makes the search very slow when the autocomplete doesn't work the way it used to.

Thank you.
Comment 4 Laura Escamilla 2023-03-09 17:11:35 UTC Comment hidden (obsolete)
Comment 5 Laura Escamilla 2023-03-09 17:15:45 UTC
Caught an error. I will work on updating the patch.
Comment 6 Laura Escamilla 2023-03-09 19:14:04 UTC Comment hidden (obsolete)
Comment 7 Laura Escamilla 2023-03-10 16:55:10 UTC Comment hidden (obsolete)
Comment 8 Laura Escamilla 2023-03-13 17:12:19 UTC Comment hidden (obsolete)
Comment 9 Tomás Cohen Arazi 2023-03-13 18:19:22 UTC
Hi, Laura. I see the ticket still 'ASSIGNED', is it ready for testers to look at it?
Comment 10 Laura Escamilla 2023-03-13 19:03:22 UTC
Created attachment 148138 [details] [review]
Bug 33117: Added new syspref Patronautocompletesesarchmethod

Added a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons. The "Contains" option should be useful when
searching for patrons that have multiple surnames or when searching
using a patron's middle name.

Test Plan:
1. Create a patron that has a first name, middle name and two surnames. (i.e. Adela Maria, Hernandez Acosta).
2. Search for the patron using their first name and first surname. Confirm that a record is found.
3. Search for the patron using their first name and second surname. Confirm that no record is found.
4. Search for the patron using their middle name and first surname. Confirm that a record is found.
5. Search for the patron using their middle name and second surname. Confirm that no record is found.
6. Apply the patch.
7. Under Administration > Global System Preferences > search for “PatronAutocompleteSearchMethod”
8. Choose “Contains” instead of “Starts with” for the system preference.
9. Repeat steps 2-4. The patron record should appear for all search methods.
10. Sign off!
Comment 11 Laura Escamilla 2023-03-13 19:04:49 UTC
(In reply to Tomás Cohen Arazi from comment #9)
> Hi, Laura. I see the ticket still 'ASSIGNED', is it ready for testers to
> look at it?

Hi Tomas. Not quite yet! I haven't switched it to Needs Signoff because I'm still working on it.
Comment 12 Laura Escamilla 2023-03-16 17:14:23 UTC Comment hidden (obsolete)
Comment 13 Laura Escamilla 2023-03-16 17:30:02 UTC Comment hidden (obsolete)
Comment 14 Laura Escamilla 2023-03-16 17:42:52 UTC Comment hidden (obsolete)
Comment 15 Laura Escamilla 2023-03-16 18:07:37 UTC Comment hidden (obsolete)
Comment 16 Laura Escamilla 2023-03-17 12:51:59 UTC Comment hidden (obsolete)
Comment 17 Laura Escamilla 2023-03-17 18:15:45 UTC
Created attachment 148383 [details] [review]
Bug 33117: Added new syspref Patronautocompletesesarchmethod

Added a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons. The "Contains" option should be useful when
searching for patrons that have multiple surnames or when searching
using a patron's middle name.

Test Plan:
1. Create a patron that has a first name, middle name and two surnames. (i.e. Adela Maria, Hernandez Acosta).
2. Search for the patron using their first name and first surname. Confirm that a record is found.
3. Search for the patron using their first name and second surname. Confirm that no record is found.
4. Search for the patron using their middle name and first surname. Confirm that a record is found.
5. Search for the patron using their middle name and second surname. Confirm that no record is found.
6. Apply the patch.
7. Under Administration > Global System Preferences > search for “PatronAutocompleteSearchMethod”
8. Choose “Contains” instead of “Starts with” for the system preference.
9. Repeat steps 2-4. The patron record should appear for all search methods.
10. Sign off!
Comment 18 ByWater Sandboxes 2023-03-17 19:07:49 UTC
Created attachment 148384 [details] [review]
Bug 33117: Added new syspref Patronautocompletesesarchmethod

Added a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons. The "Contains" option should be useful when
searching for patrons that have multiple surnames or when searching
using a patron's middle name.

Test Plan:
1. Create a patron that has a first name, middle name and two surnames. (i.e. Adela Maria, Hernandez Acosta).
2. Search for the patron using their first name and first surname. Confirm that a record is found.
3. Search for the patron using their first name and second surname. Confirm that no record is found.
4. Search for the patron using their middle name and first surname. Confirm that a record is found.
5. Search for the patron using their middle name and second surname. Confirm that no record is found.
6. Apply the patch.
7. Under Administration > Global System Preferences > search for “PatronAutocompleteSearchMethod”
8. Choose “Contains” instead of “Starts with” for the system preference.
9. Repeat steps 2-4. The patron record should appear for all search methods.
10. Sign off!

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 19 Laura Escamilla 2023-03-21 12:20:50 UTC Comment hidden (obsolete)
Comment 20 Laura Escamilla 2023-03-21 12:44:44 UTC
Created attachment 148445 [details] [review]
Bug 33117: Added new syspref Patronautocompletesesarchmethod

*Made a few minor syntax changes*

Added a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons. The "Contains" option should be useful when
searching for patrons that have multiple surnames or when searching
using a patron's middle name.

New Test Plan:
 0. Ensure system preference PatronAutoComplete is set to Try
 1. Create a patron that has a first name, middle name and two surnames. (i.e. Adela Maria, Hernandez Acosta).
 2. In patron or checkout search, enter their first name and first surname without submitting.
 3. Confirm that a record is found in the autocomplete results
 4. In patron or checkout search, enter their first name and second surname without submitting.
 5. Confirm that no record is found.
 6. Enter their middle name and first surname. Confirm that no record is found.
 7. Enter their middle name and second surname. Confirm that no record is found.
 8. Apply the patch, update database
 9. Under Administration > Global System Preferences > search for "PatronAutocompleteSearchMethod"
10. Choose "Contains" instead of "Starts with" for the system preference.
11. Repeat steps 2-4. The patron record should appear for all search methods.
12. Sign off!
Comment 21 Nick Clemens 2023-03-21 13:23:02 UTC
Created attachment 148467 [details] [review]
Bug 33117: Added new syspref Patronautocompletesesarchmethod

This patch adds a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons.

The "Contains" option should be useful when
searching for patrons that have multiple surnames or when searching
using a patron's middle name.

New Test Plan:
 0. Ensure system preference PatronAutoComplete is set to Try
 1. Create a patron that has a first name, middle name and two surnames. (i.e. Adela Maria, Hernandez Acosta).
 2. In patron or checkout search, enter their first name and first surname without submitting.
 3. Confirm that a record is found in the autocomplete results
 4. In patron or checkout search, enter their first name and second surname without submitting.
 5. Confirm that no record is found.
 6. Enter their middle name and first surname. Confirm that no record is found.
 7. Enter their middle name and second surname. Confirm that no record is found.
 8. Apply the patch, update database
 9. Under Administration > Global System Preferences > search for "PatronAutocompleteSearchMethod"
10. Choose "Contains" instead of "Starts with" for the system preference, reload your search page
11. Repeat steps 2-4. The patron record should appear for all search methods.
12. Sign off!
Comment 22 ByWater Sandboxes 2023-03-21 14:51:19 UTC
Created attachment 148481 [details] [review]
Bug 33117: Added new syspref Patronautocompletesesarchmethod

This patch adds a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons.

The "Contains" option should be useful when
searching for patrons that have multiple surnames or when searching
using a patron's middle name.

New Test Plan:
 0. Ensure system preference PatronAutoComplete is set to Try
 1. Create a patron that has a first name, middle name and two surnames. (i.e. Adela Maria, Hernandez Acosta).
 2. In patron or checkout search, enter their first name and first surname without submitting.
 3. Confirm that a record is found in the autocomplete results
 4. In patron or checkout search, enter their first name and second surname without submitting.
 5. Confirm that no record is found.
 6. Enter their middle name and first surname. Confirm that no record is found.
 7. Enter their middle name and second surname. Confirm that no record is found.
 8. Apply the patch, update database
 9. Under Administration > Global System Preferences > search for "PatronAutocompleteSearchMethod"
10. Choose "Contains" instead of "Starts with" for the system preference, reload your search page
11. Repeat steps 2-4. The patron record should appear for all search methods.
12. Sign off!

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 23 Andrew Fuerste-Henry 2023-03-21 14:52:35 UTC
I also confirmed that the searches in steps 5 and 6 both work with PatronAutocompleteSearchMethod set to Contains and then leaving PatronAutocompleteSearchMethod set to Starts With maintains all of the pre-patch behavior.
Comment 24 Jonathan Druart 2023-03-22 13:14:32 UTC
Why are you passing the syspref value to the patron_autocomplete JS function, instead of retrieving the value from there?

I think you should create a global JS variable (in doc-head-close.inc for instance), then use it when you need it in patron_autocomplete.

Also you are using TT syntax in 2 js files (tags-review.js and viewlog.js), it won't work.
Comment 25 Laura Escamilla 2023-03-23 18:41:34 UTC
(In reply to Jonathan Druart from comment #24)
> Why are you passing the syspref value to the patron_autocomplete JS
> function, instead of retrieving the value from there?
> 
> I think you should create a global JS variable (in doc-head-close.inc for
> instance), then use it when you need it in patron_autocomplete.
> 
> Also you are using TT syntax in 2 js files (tags-review.js and viewlog.js),
> it won't work.


Thanks for the feedback. I'll look into how to adjust this.
Comment 26 Laura Escamilla 2023-05-05 17:28:09 UTC
Created attachment 150781 [details] [review]
Bug 33117: New System Preference PatronAutoCompleteSearchMethod

WIP - NOT READY FOR TESTING
Comment 27 Laura Escamilla 2023-05-09 17:25:51 UTC
Created attachment 150896 [details] [review]
Bug 33117: New System Preference PatronAutoCompleteSearchMethod

WIP - Not ready for testing
Comment 28 Laura Escamilla 2023-05-09 17:37:35 UTC
Created attachment 150897 [details] [review]
Bug 33117: New System Preference PatronAutoCompleteSearchMethod

WIP - Fixing up syntax errors - NOT READY FOR TESTING
Comment 29 Laura Escamilla 2023-05-09 18:07:52 UTC
Created attachment 150898 [details] [review]
Bug 33117: New System Preference PatronAutoCompleteSearchMethod

Still a WIP -
Comment 30 Laura Escamilla 2023-05-11 18:04:51 UTC
Created attachment 151090 [details] [review]
Bug 33117: New System Preference PatronAutoCompleteSearchMethod

Still working on this --
Comment 31 Laura Escamilla 2023-05-11 18:43:39 UTC
Created attachment 151091 [details] [review]
Bug 33117: Adding new system preference for patron searching
Comment 32 Laura Escamilla 2023-05-16 15:11:59 UTC
Created attachment 151302 [details] [review]
Bug 33117: Adding new system preference for patron searching
Comment 33 Laura Escamilla 2023-05-16 16:12:45 UTC
Created attachment 151314 [details] [review]
Bug 33117: Adding new system preference for patron searching
Comment 34 Laura Escamilla 2023-05-16 18:53:37 UTC
Created attachment 151317 [details] [review]
Bug 33117: Adding new system preference for patron searching
Comment 35 Jonathan Druart 2023-05-17 06:49:53 UTC
Laura, let me know if you need help here.

I would suggest to use strings as codes for the syspref, 'start_with' and 'contains', instead of a boolean value.
Comment 36 Jonathan Druart 2023-05-17 06:50:12 UTC
* use strings instead of codes
Comment 37 Laura Escamilla 2023-05-26 16:57:20 UTC Comment hidden (obsolete)
Comment 38 Laura Escamilla 2023-05-26 21:09:36 UTC
Created attachment 151771 [details] [review]
Bug 33117: New system preference - PatronAutoCompleteSearchMethod

New Test Plan:
 0. Ensure system preference PatronAutoComplete is set to Try
 1. Create a patron that has a first name, middle name and two surnames. (i.e. Adela Maria, Hernandez Acosta).
 2. In patron or checkout search, enter their first name and first surname without submitting.
 3. Confirm that a record is found in the autocomplete results
 4. In patron or checkout search, enter their first name and second surname without submitting.
 5. Confirm that no record is found.
 6. Enter their middle name and first surname. Confirm that no record is found.
 7. Enter their middle name and second surname. Confirm that no record is found.
 8. Apply the patch, update database
 9. Under Administration > Global System Preferences > search for "PatronAutocompleteSearchMethod"
10. Choose "Contains" instead of "Starts with" for the system preference, reload your search page
11. Repeat steps 2-4. The patron record should appear for all search methods.
12. Sign off!
Comment 39 Katrin Fischer 2023-05-29 15:20:31 UTC
Hi Laura, 

this needs some more work:

1) The database update doesn't work correctly:

 FAIL	installer/data/mysql/atomicupdate/bug_33117.pl
   FAIL	  valid
		syntax error
		  (Might be a runaway multi-line {} string starting on line 10)
		syntax error
		Missing right curly or square bracket
		installer/data/mysql/atomicupdate/bug_33117.pl had compilation errors.

DEV atomic update /kohadevbox/koha/installer/data/mysql/atomicupdate/bug_33117.pl  [15:19:11]
ERROR - {UNKNOWN}: Can't use an undefined value as a subroutine reference at /kohadevbox/koha/C4/Installer.pm line 741. at /kohadevbox/koha/C4/Installer.pm line 743


2) There are some issues with the 'metadata' of the patches:

	* Author 'John Doe' seems invalid
	* Author 'John Doe' seems invalid
	* Email's author 'you@example.com' seems invalid
	* Email's author 'you@example.com' seems invalid


Can you please have a look?
Comment 40 Laura Escamilla 2023-05-30 19:52:55 UTC Comment hidden (obsolete)
Comment 41 Laura Escamilla 2023-05-30 20:26:24 UTC
Created attachment 151845 [details] [review]
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference
Comment 42 Laura Escamilla 2023-05-30 21:24:10 UTC Comment hidden (obsolete)
Comment 43 Laura Escamilla 2023-06-02 18:15:35 UTC
Test Plan:
 0. Ensure system preference PatronAutoComplete is set to Try
 1. Create a patron that has a first name, middle name and two surnames. (i.e. Adela Maria, Hernandez Acosta).
 2. In patron or checkout search, enter their first name and first surname without submitting.
 3. Confirm that a record is found in the autocomplete results
 4. In patron or checkout search, enter their first name and second surname without submitting.
 5. Confirm that no record is found.
 6. Enter their middle name and first surname. Confirm that no record is found.
 7. Enter their middle name and second surname. Confirm that no record is found.
 8. Apply the patch, update database
 9. Under Administration > Global System Preferences > search for "PatronAutocompleteSearchMethod"
10. Choose "Contains" instead of "Starts with" for the system preference, reload your search page
11. Repeat steps 2-4. The patron record should appear for all search methods.
12. Sign off!
Comment 44 Barbara Johnson 2023-06-02 19:16:39 UTC
This is mostly working.  Here is what I found in my testing:

When searching via 'Check out' from the searchbar all combinations of names displayed in the autocomplete results.  After typing in a name and hitting 'enter' all four combinations opened up the patron record.

When searching via 'Patrons' from the searchbar all combinations of names displayed in the autocomplete results.  However, only the search containing the combination of the first name and first surname brought up the patron.  The other three combinations did not find the patron record.

When searching for patrons via the patron form on the left side on members-home.pl all four combinations brought up the patron record.

So something is still preventing actually bringing up the patron record for the following combinations when using the 'Search patrons' option from the searchbar:
  --first name, second surname
  --middle name, first surname
  --middle name, second surname
Comment 45 George Williams (NEKLS) 2023-06-15 18:59:03 UTC
Because of the work done on bug 33117, we currently have a situation where the default search in the header search bar is "Starts with" but the default search in the search box on the left hand side of the page on members-home.pl is "Contains."

This is very confusing for library staff.

Whatever happens next with this patch, this new system preference should make the default search type match in the header search bar and on members-home.pl
Comment 46 George Williams (NEKLS) 2023-06-15 19:04:04 UTC
Excuse me, I meant to say because of the work done on bug 32772.  That's the bug that's caused the search type to be different in its two different appearances.
Comment 47 Martin Renvoize 2023-06-22 11:25:26 UTC
Created attachment 152549 [details] [review]
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference

This patch adds a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons.

The "Contains" option should be useful when searching for patrons that have
multiple surnames or when searching using a patron's middle name.

New Test Plan:
 0. Ensure system preference PatronAutoComplete is set to Try
 1. Create a patron that has a first name, middle name and two surnames.
    (i.e. Adela Maria, Hernandez Acosta).
 2. In patron or checkout search, enter their first name and first
    surname without submitting.
 3. Confirm that a record is found in the autocomplete results
 4. In patron or checkout search, enter their first name and second
    surname without submitting.
 5. Confirm that no record is found.
 6. Enter their middle name and first surname. Confirm that no record is
    found.
 7. Enter their middle name and second surname. Confirm that no record
    is found.
 8. Apply the patch, update database
 9. Under Administration > Global System Preferences > search for
    "PatronAutocompleteSearchMethod"
10. Choose "Contains" instead of "Starts with" for the system
    preference, reload your search page
11. Repeat steps 2-4. The patron record should appear for all search
    methods.
12. Sign off!

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 48 Martin Renvoize 2023-06-22 11:26:22 UTC
Created attachment 152552 [details] [review]
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference

This patch adds a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons.

The "Contains" option should be useful when searching for patrons that have
multiple surnames or when searching using a patron's middle name.

New Test Plan:
 0. Ensure system preference PatronAutoComplete is set to Try
 1. Create a patron that has a first name, middle name and two surnames.
    (i.e. Adela Maria, Hernandez Acosta).
 2. In patron or checkout search, enter their first name and first
    surname without submitting.
 3. Confirm that a record is found in the autocomplete results
 4. In patron or checkout search, enter their first name and second
    surname without submitting.
 5. Confirm that no record is found.
 6. Enter their middle name and first surname. Confirm that no record is
    found.
 7. Enter their middle name and second surname. Confirm that no record
    is found.
 8. Apply the patch, update database
 9. Under Administration > Global System Preferences > search for
    "PatronAutocompleteSearchMethod"
10. Choose "Contains" instead of "Starts with" for the system
    preference, reload your search page
11. Repeat steps 2-4. The patron record should appear for all search
    methods.
12. Sign off!

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 49 Martin Renvoize 2023-06-22 11:29:41 UTC
I fixed the authorship, tidied the DB update and then tested.

For me, the test plan is all passing and I couldn't replicate the issues raised by Barbara.

I think we should come back to the consistency between interfaces in another bug.. mostly because I think this is an important fix and when I tried to follow-up to make the various interfaces consistent I found there was more than I expected.. (hint, just passing searchtype from the various controllers isn't enough.. the forms don't respect the param for some reason)

So.. with that in mind, I'm happy to PQA this patch and open a new bug to work on the consistency work.
Comment 50 Martin Renvoize 2023-06-22 11:33:13 UTC
My only caveat here is the preference name.. I'd be tempted to drop the 'AutoComplete' part and have it as just `DefaultPatronSearchMethod` and sit it next to `DefaultPatronSearchFields`

I'll do a follow-up for that now.
Comment 51 Martin Renvoize 2023-06-22 11:41:06 UTC Comment hidden (obsolete)
Comment 52 Martin Renvoize 2023-06-22 11:48:09 UTC Comment hidden (obsolete)
Comment 53 Martin Renvoize 2023-06-22 12:01:26 UTC Comment hidden (obsolete)
Comment 54 Martin Renvoize 2023-06-22 13:36:28 UTC Comment hidden (obsolete)
Comment 55 Martin Renvoize 2023-06-22 13:44:13 UTC
Created attachment 152563 [details] [review]
Bug 33117: Adding new PatronAutoCompleteSearchMethod system preference

This patch adds a new system preference called "PatronAutoCompleteSearchMethod"
which allows staff to choose between "Starts with" or "Contains" when
searching for patrons.

The "Contains" option should be useful when searching for patrons that have
multiple surnames or when searching using a patron's middle name.

New Test Plan:
 0. Ensure system preference PatronAutoComplete is set to Try
 1. Create a patron that has a first name, middle name and two surnames.
    (i.e. Adela Maria, Hernandez Acosta).
 2. In patron or checkout search, enter their first name and first
    surname without submitting.
 3. Confirm that a record is found in the autocomplete results
 4. In patron or checkout search, enter their first name and second
    surname without submitting.
 5. Confirm that no record is found.
 6. Enter their middle name and first surname. Confirm that no record is
    found.
 7. Enter their middle name and second surname. Confirm that no record
    is found.
 8. Apply the patch, update database
 9. Under Administration > Global System Preferences > search for
    "PatronAutocompleteSearchMethod"
10. Choose "Contains" instead of "Starts with" for the system
    preference, reload your search page
11. Repeat steps 2-4. The patron record should appear for all search
    methods.
12. Sign off!

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 56 Martin Renvoize 2023-06-22 13:44:17 UTC
Created attachment 152564 [details] [review]
Bug 33117: (follow-up) Rename preference

As it's been requested that we keep the search defaults consistent, I
think this preference is better names DefaultPatronSearchMethod and
appear next to DefaultPatronSearchFields. This patch makes that change,
though actually applying it to the other search area's (outside of
autocomplete) has been left for another bug.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 57 Martin Renvoize 2023-06-22 13:44:21 UTC Comment hidden (obsolete)
Comment 58 Tomás Cohen Arazi 2023-06-23 12:46:02 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 59 Martin Renvoize 2023-07-17 14:02:49 UTC
Thanks for all the hard work!

Pushed to 23.05.x for the next release
Comment 60 Pedro Amorim 2023-07-18 11:54:25 UTC
Nice work everyone!

Pushed to 22.11.x for next release
Comment 61 Andrii Nugged 2023-07-27 18:36:14 UTC
Note: non-idempotent atomic update.

INSERT INTO systempreferences
->
INSERT IGNORE INTO systempreferences
Comment 62 Fridolin Somers 2023-08-03 21:53:29 UTC
Indeed, fix needed in installer/data/mysql/db_revs/230600006.pl
Comment 63 Tomás Cohen Arazi 2023-08-07 18:30:45 UTC
Created attachment 154309 [details] [review]
Bug 33117: Make dbrev idempotent

QA didn't spot the issue, nor I. So fixing now.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 64 Tomás Cohen Arazi 2023-08-07 19:12:19 UTC
Follow-up pushed to master.

@RMaints please port the last patch.
Comment 65 Fridolin Somers 2023-08-07 20:57:45 UTC
Done for 23.05.x
Comment 66 Pedro Amorim 2023-08-17 16:05:49 UTC
Nice work everyone!

Pushed to 22.11.x for next release
Comment 67 Manos PETRIDIS 2023-08-22 10:24:29 UTC
I wonder if bug https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34580 is related to changes introduced here.
Comment 68 Fridolin Somers 2023-08-24 18:53:55 UTC Comment hidden (obsolete)
Comment 69 Fridolin Somers 2023-08-24 18:58:27 UTC
(In reply to Manos PETRIDIS from comment #67)
> I wonder if bug
> https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34580 is related
> to changes introduced here.

Indeed.

This is fixed in 23.05.03 with patch "Bug 33117: Make dbrev idempotent"
https://git.koha-community.org/Koha-community/Koha/commits/branch/23.05.x/search?q=33117
Comment 70 Jonathan Druart 2023-08-30 11:27:24 UTC
Added test to QA script (we had it for updatedatabase.pl)

https://gitlab.com/koha-community/qa-test-tools/-/issues/74!
Comment 71 Caroline Cyr La Rose 2024-01-12 16:21:04 UTC
Just a note that for people updating from before 22.11 (we updated from 22.05 to 23.05), the new syspref default (starts with) changes the historic behaviour (contains).

The default keeps the "new" behaviour introduced by the regression.

Something to keep in mind when updating. We had to change the syspref in all our client installations after several clients reported having problems with the search.