Bug 40313 - Legacy/migrated categorycode can break patron save
Summary: Legacy/migrated categorycode can break patron save
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-07 01:58 UTC by David Cook
Modified: 2025-07-07 02:59 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40313: Prevent jQuery error when saving patron with bad categorycode (2.29 KB, patch)
2025-07-07 02:07 UTC, David Cook
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2025-07-07 01:58:57 UTC
This should be quite an edge case, but if you have done a data migration and have category codes like "(ABC123", you may notice that you cannot edit your patrons.

Due to some suboptimal Javascript, the "(" gets erroneously interpreted by jQuery and leads to an error which breaks other Javascript and prevents the page save from working.
Comment 2 David Cook 2025-07-07 02:07:36 UTC
Created attachment 183819 [details] [review]
Bug 40313: Prevent jQuery error when saving patron with bad categorycode

This patch prevents a problem string from being passed to $().

Out of the box, this shouldn't be a problem, but if you migrate categorycodes
from another system which may or may not include the "(" character in them,
you'll find you cannot edit and save these patrons anymore due to a Javascript
error.

To reproduce:
0. DO NOT APPLY THE PATCH
1. Create a new patron category with a code called "TEST"
2. In the mysql client, change this patron category code to "(TEST"
3. Create a new patron with this category
4. Try to edit and save the patron
5. Note you cannot (and if you open the browser console, you'll see JS errors)

Test plan:
0. Apply the patch
1. Try to edit and save the patron from above
2. Note that you can now save the patron

Bonus points:
0. Edit the new patron category to have a password length of 16 or higher
1. Create a patron attribute just for this new patron category
2. Test editing patrons by changing the category to this TEST category
and other established categories.
3. Note that the password length and patron attributes change as you
change the category