Bug 26797

Summary: Error when trying to access Relative Checkouts between Professional and Organizational patron categories
Product: Koha Reporter: Kelly McElligott <kelly>
Component: PatronsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: andrew, caroline.cyr-la-rose, fridolin.somers, gmcharlt, jonathan.druart, jzairo, kyle.m.hall, nick, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27133
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.02
Circulation function:
Attachments: Bug 26797: Escape firstname to prevent relative's checkouts to crash
Bug 26797: Escape firstname to prevent relative's checkouts to crash
Bug 26797: Escape firstname to prevent relative's checkouts to crash

Description Kelly McElligott 2020-10-23 12:37:59 UTC
In Koha 20.05 and 19.11, when a Professional Patron Category patron and an Organizational patron category patron are linked, from the Professional patron, there is a tab to see the 'Relative Checkouts', but Koha just will spin and say processing.  

Koha is looking for a first name to link the relative checkouts from a professional to the linked Organizational patron.  On an organizational patron, there is no first name and therefore Koha can not do the link.
Comment 1 Jonathan Druart 2020-12-02 10:12:02 UTC
*** Bug 26796 has been marked as a duplicate of this bug. ***
Comment 2 Jonathan Druart 2020-12-02 10:25:29 UTC
Confirmed on master.
Comment 3 Jonathan Druart 2020-12-02 10:28:28 UTC
Created attachment 114091 [details] [review]
Bug 26797: Escape firstname to prevent relative's checkouts to crash

If no firstname is defined for a relative, the "Relative's checkouts"
tab will be "processing" forever.
JS error:
  TypeError: oObj.borrower.firstname is null

Test plan:
Patron A is Org and guarantor of patron B
Check an item out to B
Go to the details page of A, click "Relative's checkouts"
Comment 4 Jonathan Druart 2020-12-02 10:31:03 UTC
Note that there is a UI issue display (header number mismatch).
See bug 27133.
Comment 5 Kelly McElligott 2020-12-02 15:00:00 UTC
Created attachment 114099 [details] [review]
Bug 26797: Escape firstname to prevent relative's checkouts to crash

If no firstname is defined for a relative, the "Relative's checkouts"
tab will be "processing" forever.
JS error:
  TypeError: oObj.borrower.firstname is null

Test plan:
Patron A is Org and guarantor of patron B
Check an item out to B
Go to the details page of A, click "Relative's checkouts"

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Comment 6 Victor Grousset/tuxayo 2020-12-12 14:32:56 UTC
I have an organization (school) with a guarantee that doesn't have a firstname. (empty string, also tested with a patron created without firstname)
But I don't have an error in the console and the table loads.
What is missing in my test plan?

https://picat.drycat.fr/aXxAy7eU.png

I even tried with a library being the guarantee of a school.
Comment 7 Nick Clemens (kidclamp) 2021-01-08 19:07:25 UTC
Created attachment 114977 [details] [review]
Bug 26797: Escape firstname to prevent relative's checkouts to crash

If no firstname is defined for a relative, the "Relative's checkouts"
tab will be "processing" forever.
JS error:
  TypeError: oObj.borrower.firstname is null

Test plan:
1 - Create a patron (PatronA) in a category with type 'Org'
    'School' in sample data works
2 - Add a guarantee (Patron B)
3 - Check out an item to PatronA
4 - Go to PatronB's record and click relativwe's checkouts
5 - There is an error and the table doe snot load
6 - Apply patch
7 - Reload
8 - Table loads correctly

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Nick Clemens (kidclamp) 2021-01-08 19:08:06 UTC
(In reply to Victor Grousset/tuxayo from comment #6)
> I have an organization (school) with a guarantee that doesn't have a
> firstname. (empty string, also tested with a patron created without
> firstname)
> But I don't have an error in the console and the table loads.
> What is missing in my test plan?
> 
> https://picat.drycat.fr/aXxAy7eU.png
> 
> I even tried with a library being the guarantee of a school.

The patch was correct, the test plan was wrong - the guarantee could not load the checkouts for the guarantor
Comment 9 Jonathan Druart 2021-01-11 09:30:06 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 10 Fridolin Somers 2021-01-11 13:01:15 UTC
Pushed to 20.11.x for 20.11.02
Comment 11 Andrew Fuerste-Henry 2021-01-20 01:09:15 UTC
This doesn't fix the issue for me in 20.05. Patch applies fine, but I get this error when trying to see the Org's checkoouts in the prof's record:

checkouts_20.0507002.js:785 Uncaught TypeError: Cannot read property 'escapeHtml' of null
    at mDataProp (checkouts_20.0507002.js:785)
    at datatables.min_20.0507002.js:57
    at Object.b.fnGetData (datatables.min_20.0507002.js:51)
    at B (datatables.min_20.0507002.js:56)
    at Ha (datatables.min_20.0507002.js:64)
    at O (datatables.min_20.0507002.js:55)
    at datatables.min_20.0507002.js:88
    at i (datatables.min_20.0507002.js:74)
    at Object.success (checkouts_20.0507002.js:802)
    at i (jquery-2.2.3.min_20.0507002.js:2)

Jonathan, any ideas?
Comment 12 Jonathan Druart 2021-01-20 08:31:25 UTC
Andrew, it looks like a cache issue, can you confirm the cache has been correctly flushed?