Bug 38974

Summary: Error when submitting patron update from the OPAC Can't call method "dateofbirthrequired" on an undefined value
Product: Koha Reporter: Owen Leonard <oleonard>
Component: OPACAssignee: Andreas Jonsson <andreas.jonsson>
Status: Pushed to stable --- QA Contact: Marcel de Rooy <m.de.rooy>
Severity: major    
Priority: P5 - low CC: andreas.jonsson, david, lucas, m.de.rooy
Version: MainKeywords: rel_24_11_candidate
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
This fixes updating personal details in the OPAC. A 500 error was shown if the "Patron category (categorycode)" was selected in the PatronSelfModificationBorrowerUnwantedField system preference and the date of birth field was changed or previously empty.
Version(s) released in:
25.11.00,25.05.01
Circulation function:
Attachments: Bug 38974: Fix error in OPAC patron update
Bug 38974: Fix error in OPAC patron update
Bug 38974: Fix error in OPAC patron update

Description Owen Leonard 2025-01-27 12:52:20 UTC
I'm seeing an error in main when submitting a patron update from the OPAC. It seems to happen only when the submission includes a date of birth value.

It happens when adding a new date of birth value (previously empty), when submitting a change to the date of birth value, or when submitting the form without changing the date of birth field. It doesn't seem to be connected to the dateofbirth system preference choice.

Can't call method "dateofbirthrequired" on an undefined value at /kohadevbox/koha/opac/opac-memberentry.pl line 539
Comment 1 Andreas Jonsson 2025-05-22 09:12:20 UTC
Created attachment 182722 [details] [review]
Bug 38974: Fix error in OPAC patron update

Test plan:

1) Make sure Patron category is checked in the system preference PatronSelfModificationBorrowerUnwantedField
2) Log in to the opac
3) Go to "Personal details"
4) Select any value for "Date of birth"
5) Click save
6) This must not yield error 500. (But may be a successful save or a validation error).
Comment 2 David Nind 2025-05-22 22:49:32 UTC
Created attachment 182746 [details] [review]
Bug 38974: Fix error in OPAC patron update

Test plan:

1) Make sure Patron category is checked in the system preference PatronSelfModificationBorrowerUnwantedField
2) Log in to the opac
3) Go to "Personal details"
4) Select any value for "Date of birth"
5) Click save
6) This must not yield error 500. (But may be a successful save or a validation error).

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2025-05-22 22:53:28 UTC
Testing notes (using KTD):
1. The "Patron category (categorycode)" field to select for PatronSelfModificationBorrowerUnwantedField is about three quarters of the way down the list on the left-hand side.
Comment 4 Marcel de Rooy 2025-06-06 07:50:46 UTC
Please fill assignee field when taking a bug.
Comment 5 Marcel de Rooy 2025-06-06 07:51:49 UTC
Looks like this is affected too by this change:

    if ( $borrower->{'password'} ) {
        my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid(
            $borrower->{password},
            Koha::Patron::Categories->find(
                $borrower->{categorycode} || C4::Context->preference('PatronSelfRegistrationDefaultCategory')

And should be more correct now (when updating).
Comment 6 Marcel de Rooy 2025-06-06 07:52:59 UTC
Created attachment 183053 [details] [review]
Bug 38974: Fix error in OPAC patron update

Test plan:

1) Make sure Patron category is checked in the system preference PatronSelfModificationBorrowerUnwantedField
2) Log in to the opac
3) Go to "Personal details"
4) Select any value for "Date of birth"
5) Click save
6) This must not yield error 500. (But may be a successful save or a validation error).

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Lucas Gass (lukeg) 2025-06-06 15:43:37 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 8 Paul Derscheid 2025-06-22 21:46:58 UTC
Nice work everyone!

Pushed to 25.05.x for 25.05.03