Bug 28213

Summary: Deleting a patron or patron club causes server error on searching
Product: Koha Reporter: Andrew Fuerste-Henry <andrew>
Component: SearchingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, martin.renvoize, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28214
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.06,20.05.12
Circulation function:
Attachments: Bug 28213: Prevent crash if patron or club deleted after search to hold
Bug 28213: Prevent crash if patron or club deleted after search to hold
Bug 28213: Prevent crash if patron or club deleted after search to hold
Bug 28213: Prevent crash if patron or club deleted after search to hold

Description Andrew Fuerste-Henry 2021-04-24 14:58:25 UTC
To recreate:
- create a club template
- create a club
- enroll a patron in the club
- from the clubs page, select Search To Hold for your club
- do a search, see that it says "Hold for [club name]" in your search results page
- go back to the clubs page and delete your club
- try to perform a search
- get error "Can't call method "name" on an undefined value at /kohadevbox/koha/catalogue/search.pl line 207"

Koha's trying to retain your deleted club as its Search To Hold target.
Comment 1 Jonathan Druart 2021-04-26 09:16:08 UTC
Created attachment 120168 [details] [review]
Bug 28213: Prevent crash if patron or club deleted after search to hold

Deleting a patron or patron club causes server error on searching.

To recreate:
- create a club template
- create a club
- enroll a patron in the club
- from the clubs page, select Search To Hold for your club
- do a search, see that it says "Hold for [club name]" in your search results page
- go back to the clubs page and delete your club
- try to perform a search
=> Without this patch you get "Can't call method "name" on an undefined value at /kohadevbox/koha/catalogue/search.pl line 207"

Same when placing a hold for a patron
Comment 2 Andrew Fuerste-Henry 2021-04-26 14:36:17 UTC
Looks like there's still an error on the bib detail page. I searched for hold from a patron and deleted them. The search results page didn't give an error, but I got this when I clicked through to bib details:

Can't call method "surname" on an undefined value at /kohadevbox/koha/catalogue/detail.pl line 97
Comment 3 Jonathan Druart 2021-04-26 14:59:13 UTC
Created attachment 120177 [details] [review]
Bug 28213: Prevent crash if patron or club deleted after search to hold

Deleting a patron or patron club causes server error on searching.

To recreate:
- create a club template
- create a club
- enroll a patron in the club
- from the clubs page, select Search To Hold for your club
- do a search, see that it says "Hold for [club name]" in your search results page
- go back to the clubs page and delete your club
- try to perform a search
=> Without this patch you get "Can't call method "name" on an undefined value at /kohadevbox/koha/catalogue/search.pl line 207"

Same when placing a hold for a patron (check the search result and the
detail pages)
Comment 4 Andrew Fuerste-Henry 2021-04-26 18:11:41 UTC
Created attachment 120182 [details] [review]
Bug 28213: Prevent crash if patron or club deleted after search to hold

Deleting a patron or patron club causes server error on searching.

To recreate:
- create a club template
- create a club
- enroll a patron in the club
- from the clubs page, select Search To Hold for your club
- do a search, see that it says "Hold for [club name]" in your search results page
- go back to the clubs page and delete your club
- try to perform a search
=> Without this patch you get "Can't call method "name" on an undefined value at /kohadevbox/koha/catalogue/search.pl line 207"

Same when placing a hold for a patron (check the search result and the
detail pages)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 5 Andrew Fuerste-Henry 2021-04-26 18:12:59 UTC
Thanks for the quick patch!
Comment 6 Andrew Fuerste-Henry 2021-04-26 18:13:20 UTC
*** Bug 28214 has been marked as a duplicate of this bug. ***
Comment 7 Martin Renvoize (ashimema) 2021-04-27 14:18:53 UTC
Created attachment 120238 [details] [review]
Bug 28213: Prevent crash if patron or club deleted after search to hold

Deleting a patron or patron club causes server error on searching.

To recreate:
- create a club template
- create a club
- enroll a patron in the club
- from the clubs page, select Search To Hold for your club
- do a search, see that it says "Hold for [club name]" in your search results page
- go back to the clubs page and delete your club
- try to perform a search
=> Without this patch you get "Can't call method "name" on an undefined value at /kohadevbox/koha/catalogue/search.pl line 207"

Same when placing a hold for a patron (check the search result and the
detail pages)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 8 Martin Renvoize (ashimema) 2021-04-27 14:19:23 UTC
Trivial and obvious fix.. works as expected.

Passing QA
Comment 9 Jonathan Druart 2021-04-28 09:17:19 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 10 Fridolin Somers 2021-04-30 09:11:24 UTC
Pushed to 20.11.x for 20.11.06
Comment 11 Andrew Fuerste-Henry 2021-05-24 19:11:23 UTC
Pushed to 20.05.x for 20.05.12
Comment 12 Victor Grousset/tuxayo 2021-05-24 19:21:58 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.