Bug 33616

Summary: JavaScript error in when using claims return button in checkout table
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: CirculationAssignee: Lucas Gass (lukeg) <lucas>
Status: RESOLVED DUPLICATE QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P5 - low CC: gmcharlt, kyle.m.hall, m.de.rooy
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 33616: Make sure match() is evaluated against a string
Bug 33616: Make sure match() is evaluated against a string

Description Lucas Gass (lukeg) 2023-04-26 15:07:23 UTC
To recreate:

1. Set ClaimReturnedLostValue to a LOST value
2. Check out an item to a patron.
3. Click the Claim returned button within the checkout table.
4. Get spinning icon in place of the button
5. In the web developer tools console: Uncaught TypeError: value.match is not a function


Looks like this is coming from includes/js-date-format.inc:

 46             if ( ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) {
 47                 m = m.tz(tz);
 48             }
Comment 1 Lucas Gass (lukeg) 2023-04-26 15:24:50 UTC
match() matches a string against a regular expression. We need to make sure the value passed is a string.
Comment 2 Lucas Gass (lukeg) 2023-04-26 15:30:35 UTC
Created attachment 150248 [details] [review]
Bug 33616: Make sure match() is evaluated against a string

To Test:

1. Set ClaimReturnedLostValue to a LOST value
2. Check out an item to a patron.
3. Click the Claim returned button within the checkout table.
4. Get spinning icon in place of the button
5. In the web developer tools console: Uncaught TypeError: value.match is not a function
6. Apply patch
7. Try 2 - 3 again. This time the spinning icon should turn into a grey button with the correct date.
8. There should no longer be a console error.
Comment 3 David Nind 2023-04-26 17:27:09 UTC
Created attachment 150249 [details] [review]
Bug 33616: Make sure match() is evaluated against a string

To Test:

1. Set ClaimReturnedLostValue to a LOST value
2. Check out an item to a patron.
3. Click the Claim returned button within the checkout table.
4. Get spinning icon in place of the button
5. In the web developer tools console: Uncaught TypeError: value.match is not a function
6. Apply patch
7. Try 2 - 3 again. This time the spinning icon should turn into a grey button with the correct date.
8. There should no longer be a console error.

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 Marcel de Rooy 2023-04-28 10:46:25 UTC
(In reply to Lucas Gass from comment #1)
> match() matches a string against a regular expression. We need to make sure
> the value passed is a string.

Looks good to me. Do you know what you got that triggered the type error?
In theory we could pass something that may not have a toString method too and cause a new error? Probably not reproducable :)
Comment 5 Lucas Gass (lukeg) 2023-04-28 14:18:45 UTC
I think this is now a duplicate of Bug 33621.
Comment 6 Lucas Gass (lukeg) 2023-04-28 14:19:16 UTC

*** This bug has been marked as a duplicate of bug 33621 ***