Bug 37368

Summary: Patron searches break when surname and firstname are set to NULL
Product: Koha Reporter: Lucas Gass <lucas>
Component: PatronsAssignee: Martin Renvoize <martin.renvoize>
Status: Pushed to main --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, gmcharlt, kyle.m.hall, Laura.escamilla, martin.renvoize, stalkernoid
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes an error when searching for patrons in the staff interface (for both the search in the header and the sidebar). If you have a patron without a last name or first name, and search using a space, the search did not complete and generated a browser console error.
Version(s) released in:
24.11.00
Circulation function:
Attachments: Bug 37368: Change library.name to library_id
Bug 37368: Change library.name to library_id
Bug 37368: Add 'library' to patron search embed
Bug 37368: Add 'library' to patron search embed
Bug 37368: Add 'library' to patron search embed
Bug 37368: Add 'library' to patron search embed

Description Lucas Gass 2024-07-15 21:36:21 UTC
To recreate:

1: update borrowers set surname = NULL where borrowernumber = 19;
2. update borrowers set firstname = NULL where borrowernumber = 19;
3. Perform a patron search, see the console error:

Uncaught TypeError: patron.library is undefined

patron.library.name in js-patron-format.inc feels like a typo. Should be patron.library_id



patron.library_name isn't a thing.
Comment 1 Lucas Gass 2024-07-15 21:38:41 UTC
Created attachment 169030 [details] [review]
Bug 37368: Change library.name to library_id

To test:
1: update borrowers set surname = NULL where borrowernumber = 19;
2. update borrowers set firstname = NULL where borrowernumber = 19;
3. Perform a patron search, see the console error and the patron search never completes.
4. APPLY PATCH and try searching again.
5. Search completes.
Comment 2 David Nind 2024-07-16 01:57:30 UTC
Sorry, I can't replicate the issue. I tried in both Firefox and Chromium:

1. Go to Patrons.
2. Use the header search box to search for a patron (for example, Mary).
3. Autocomplete comes up as expected, and patron record displays as expected.
4. No console errors.
5. Same with left-hand side "Search for patron" on the Patrons page (entered Mary then the search button).
Comment 3 David Nind 2024-07-16 02:06:01 UTC
Update: I can get the console error if I enter a space in the search box and press enter, and the same with the search on the left.
Comment 4 David Nind 2024-07-16 02:06:39 UTC
Created attachment 169032 [details] [review]
Bug 37368: Change library.name to library_id

To test:
1: update borrowers set surname = NULL where borrowernumber = 19;
2. update borrowers set firstname = NULL where borrowernumber = 19;
3. Perform a patron search, see the console error and the patron search never completes.
4. APPLY PATCH and try searching again.
5. Search completes.

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 Martin Renvoize 2024-07-17 15:45:11 UTC
Created attachment 169093 [details] [review]
Bug 37368: Add 'library' to patron search embed

This patch adds the missing library embed from the patron search forms.
This embed is required for the case where a patron is missing both first
and last name or is from a different library group and thus falls into
the 'Patron from library X' block.

I also update the 'Patron from library X' to 'Patron from X' as I feel
it reads more clearly.
Comment 6 Martin Renvoize 2024-07-17 15:50:05 UTC
Created attachment 169095 [details] [review]
Bug 37368: Add 'library' to patron search embed

This patch adds the missing library embed from the patron search forms.
This embed is required for the case where a patron is missing both first
and last name or is from a different library group and thus falls into
the 'Patron from library X' block.

I also update the 'Patron from library X' to 'Patron from X' as I feel
it reads more clearly.

Finally, we need to sync the available embeds to ensure 'library' is
embeddable from the different endpoints this search can be triggered on.
Comment 7 Lucas Gass 2024-07-17 15:53:31 UTC
Created attachment 169096 [details] [review]
Bug 37368: Add 'library' to patron search embed

This patch adds the missing library embed from the patron search forms.
This embed is required for the case where a patron is missing both first
and last name or is from a different library group and thus falls into
the 'Patron from library X' block.

I also update the 'Patron from library X' to 'Patron from X' as I feel
it reads more clearly.

Finally, we need to sync the available embeds to ensure 'library' is
embeddable from the different endpoints this search can be triggered on.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 8 Kyle M Hall 2024-07-17 16:36:05 UTC
Created attachment 169106 [details] [review]
Bug 37368: Add 'library' to patron search embed

This patch adds the missing library embed from the patron search forms.
This embed is required for the case where a patron is missing both first
and last name or is from a different library group and thus falls into
the 'Patron from library X' block.

I also update the 'Patron from library X' to 'Patron from X' as I feel
it reads more clearly.

Finally, we need to sync the available embeds to ensure 'library' is
embeddable from the different endpoints this search can be triggered on.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 9 Katrin Fischer 2024-07-18 15:57:45 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 10 Katrin Fischer 2024-07-18 16:32:52 UTC
*** Bug 37327 has been marked as a duplicate of this bug. ***