From 6975b6616b3647cee3d507bd0f396aa6389584d2 Mon Sep 17 00:00:00 2001 From: Olivia Reynolds Date: Thu, 6 Aug 2026 14:20:58 +0000 Subject: [PATCH] Bug 30319: Remove appropriate hidden fields on self-modification Previously, the system preference PatronSelfRegistrationBorrowerUnwantedField was used to remove hidden fields regardless of whether the operation was self-registration or self-modification. This patch uses the appropriate set of hidden fields depending on the current operation (create/update). Test plan: 1. Set OPACPatronDetails to "Allow". 2. Ensure PatronSelfModificationBorrowerUnwantedField is empty. 3. Set PatronSelfRegistrationBorrowerUnwantedField to exclude Title (towards the bottom right of the modal). 4. Log into the OPAC, and navigate to Your account > Personal details. 5. Change your title and submit the request. 6. Verify you see the notice "No changes were made." at the top of the page. 7. Apply patch. 8. Change your title again and submit the request. 9. Verify the request is submitted successfully. 10. Return to the personal details screen, but don't submit. 11. Set PatronSelfModificationBorrowerUnwantedField to exclude Title. 12. On the preloaded personal details screen, update the title and submit. 13. Verify you see the notice "No changes were made." at the top of the page. Sponsored-by: Open Fifth Signed-off-by: David Nind Signed-off-by: Lucas Gass Signed-off-by: Pedro Amorim --- opac/opac-memberentry.pl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index fc194f6fc2..bf941cf8da 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -130,7 +130,7 @@ foreach my $attr (@$attributes) { if ( $op eq 'cud-create' ) { - my %borrower = ParseCgiForBorrower($cgi); + my %borrower = ParseCgiForBorrower( { cgi => $cgi, op => $op } ); %borrower = DelEmptyFields(%borrower); $borrower{categorycode} ||= $PatronSelfRegistrationDefaultCategory; @@ -312,7 +312,7 @@ if ( $op eq 'cud-create' ) { my $borrower = Koha::Patrons->find($borrowernumber)->unblessed; - my %borrower = ParseCgiForBorrower($cgi); + my %borrower = ParseCgiForBorrower( { cgi => $cgi, op => $op } ); $borrower{borrowernumber} = $borrowernumber; $borrower{categorycode} = $borrower->{categorycode}; @@ -565,7 +565,9 @@ sub CheckForInvalidFields { } sub ParseCgiForBorrower { - my ($cgi) = @_; + my ($params) = @_; + my $cgi = $params->{cgi}; + my $op = $params->{op}; my $scrubber = C4::Scrubber->new(); my %borrower; @@ -595,8 +597,11 @@ sub ParseCgiForBorrower { for qw/dateenrolled dateexpiry borrowernotes opacnote sort1 sort2 sms_provider_id autorenew_checkouts gonenoaddress lost relationship/ ; # On OPAC only - delete $borrower{$_} - for split( /\s*\|\s*/, C4::Context->preference('PatronSelfRegistrationBorrowerUnwantedField') || q{} ); + + # Delete fields hidden from this operation + my $mandatory = GetMandatoryFields($op); + my $hidden = GetHiddenFields( $mandatory, $op ); + delete $borrower{$_} for keys %$hidden; return %borrower; }