Bug 38847

Summary: Renewing an expired child patron without a guarantor and with ChildNeedsGuarantor set results in an internal server error
Product: Koha Reporter: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Component: PatronsAssignee: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Status: Pushed to main --- QA Contact: Nick Clemens (kidclamp) <nick>
Severity: normal    
Priority: P5 - low CC: david, gmcharlt, kyle.m.hall
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes an internal server error when renewing an expired child patron without a guarantor, when the ChildNeedsGuarantor system preference is set to "must have". It now displays a standard error message with "This patron could not be renewed: they need a guarantor."
Version(s) released in:
25.05.00
Circulation function:
Attachments: Bug 38847 - Renewing a child without guarantor whith ChildNeedsGuarantor results in an internal server error (edit) o
Bug 38847: Fix error when renewing an expired child patron without a guarantor
Bug 38847: Fix error when renewing an expired child patron without a guarantor

Description Baptiste Wojtkowski (bwoj) 2025-01-08 15:22:33 UTC
To reproduce:
1 - Create a child, make sure it has no guarantor
2 - Set ChildNeedsGuarantor to Yes
3 - Renew the child -> you will have an internal server error
Comment 1 Baptiste Wojtkowski (bwoj) 2025-01-08 15:57:54 UTC
Created attachment 176249 [details] [review]
Bug 38847 - Renewing a child without guarantor whith ChildNeedsGuarantor results in an internal server error (edit) o

Test plan:
1 - Create a child, make sure it has no guarantor
2 - Set ChildNeedsGuarantor to Yes
3 - Renew the child (on morember.pl or circulation.pl) -> you will have an internal server error
4 - Apply patch
5 - Go to moremember.pl, try and renew the patron -> you will be
  redirected to moremember with an error message
6 - Go to circulation.pl, try and renew the patron -> you will be
  redirected to circultation.pl with an error message
7 - Create a guarantor for the patron
8 - Repeat 5 & 6 and notice it is now renewed
Comment 2 David Nind 2025-01-24 22:49:30 UTC
Created attachment 177135 [details] [review]
Bug 38847: Fix error when renewing an expired child patron without a guarantor

This fixes an internal server error when renewing an expired
child patron without a guarantor, when the ChildNeedsGuarantor
is set to "must have".

Test plan:
1. Create or edit a child patron:
   - Don't add a guarantor.
   - Set the "Expiry date" to a date in the past.
2. Set the ChildNeedsGuarantor system preference to "must have".
3. Refresh or view the patron's check out or details page, and
   select the "Renew" link under the attention heading -
   this generates an internal server error message.
4. Apply patch.
5. Repeat step 3, you will now get a standard error message
   "This patron could not be renewed: they need a guarantor."
6. Add a guarantor for the patron.
7. Repeat step 3, and click "Renew" - the patron is now renewed.

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2025-01-24 22:51:53 UTC
Comment on attachment 176249 [details] [review]
Bug 38847 - Renewing a child without guarantor whith ChildNeedsGuarantor results in an internal server error (edit) o

I edited the commit message to be more consistent with the commit message guidelines - colon after the bug number in the title, description, improved the test plan, clarify that this is for when the patron's account is expired.
Comment 4 Nick Clemens (kidclamp) 2025-02-06 18:16:50 UTC
Created attachment 177589 [details] [review]
Bug 38847: Fix error when renewing an expired child patron without a guarantor

This fixes an internal server error when renewing an expired
child patron without a guarantor, when the ChildNeedsGuarantor
is set to "must have".

Test plan:
1. Create or edit a child patron:
   - Don't add a guarantor.
   - Set the "Expiry date" to a date in the past.
2. Set the ChildNeedsGuarantor system preference to "must have".
3. Refresh or view the patron's check out or details page, and
   select the "Renew" link under the attention heading -
   this generates an internal server error message.
4. Apply patch.
5. Repeat step 3, you will now get a standard error message
   "This patron could not be renewed: they need a guarantor."
6. Add a guarantor for the patron.
7. Repeat step 3, and click "Renew" - the patron is now renewed.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 5 Katrin Fischer 2025-02-12 13:46:09 UTC
Made a tiny change:

Changed:
<p>They must have a guarantor defined</p>

To:
<p>They must have a guarantor</p>

I feel "defined" is more for developers :)
Comment 6 Katrin Fischer 2025-02-12 14:28:59 UTC
Pushed for 25.05!

Well done everyone, thank you!