Bugzilla – Attachment 183819 Details for
Bug 40313
Legacy/migrated categorycode can break patron save
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40313: Prevent jQuery error when saving patron with bad categorycode
Bug-40313-Prevent-jQuery-error-when-saving-patron-.patch (text/plain), 2.29 KB, created by
David Cook
on 2025-07-07 02:07:36 UTC
(
hide
)
Description:
Bug 40313: Prevent jQuery error when saving patron with bad categorycode
Filename:
MIME Type:
Creator:
David Cook
Created:
2025-07-07 02:07:36 UTC
Size:
2.29 KB
patch
obsolete
>From 633458baa19b0029576788ec64ce0ad0353cf86b Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Mon, 7 Jul 2025 01:59:15 +0000 >Subject: [PATCH] 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 >--- > koha-tmpl/intranet-tmpl/prog/js/members.js | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js >index a20561cfe0..3593a3278d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js >@@ -71,8 +71,14 @@ function clone_entry(node) { > } > > function update_category_code(category_code) { >- if ($(category_code).is("select")) { >- category_code = $("#categorycode_entry").find("option:selected").val(); >+ //NOTE: Sometimes the category_code arg is a string and sometimes it's an object >+ const data_type = typeof category_code; >+ if (data_type === "object") { >+ if ($(category_code).is("select")) { >+ category_code = $("#categorycode_entry") >+ .find("option:selected") >+ .val(); >+ } > } > var mytables = $(".attributes_table"); > $(mytables).find("li").hide(); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40313
: 183819