From 6692800794cbf403e8be8c8062608b60148c0d56 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 8 May 2019 16:37:50 -0500 Subject: [PATCH] Bug 11853: Allow to clear the date of birth at the OPAC A patron is not able to clear their date of birth. When cleared tt is set to NULL in DB which means, for the patron's modifications feature, that nothing has been changed. Test plan: 0/ Do not apply the patch 1/ Edit your personal details at the OPAC 2/ Add a date of birth 3/ On the staff interface, approve the modification request => OK it is updated 4/ Edit your personal details and clear the date of birth 5/ On the staff interface => KO the table display is wrong, nothing is marked has changed 6/ Approve the modification requiest => KO it has not been cleared 7/ Apply the patch and repeat 1 to 6 and confirm that the behaviors are now correct. Signed-off-by: Liz Rea Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- Koha/Patron/Modification.pm | 14 +++++++++----- Koha/Patron/Modifications.pm | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Koha/Patron/Modification.pm b/Koha/Patron/Modification.pm index b0e01b7378..b5d5aded70 100644 --- a/Koha/Patron/Modification.pm +++ b/Koha/Patron/Modification.pm @@ -92,14 +92,18 @@ sub approve { delete $data->{verification_token}; delete $data->{extended_attributes}; - foreach my $key ( keys %$data ) { - delete $data->{$key} unless ( defined( $data->{$key} ) ); - } - my $patron = Koha::Patrons->find( $self->borrowernumber ); - return unless $patron; + foreach my $key ( keys %$data ) { + next # Unset it! + if $key eq 'dateofbirth' + && $patron->dateofbirth + && not defined $data->{$key}; + + delete $data->{$key} unless defined $data->{$key}; + } + $patron->set($data); # Take care of extended attributes diff --git a/Koha/Patron/Modifications.pm b/Koha/Patron/Modifications.pm index 5b424cd7d0..646d112f4c 100644 --- a/Koha/Patron/Modifications.pm +++ b/Koha/Patron/Modifications.pm @@ -132,7 +132,11 @@ sub pending { $row->{$key} = \@pending_attributes; } - delete $row->{$key} unless defined $row->{$key}; + if ( $key eq 'dateofbirth' and not defined $row->{$key}) { + $row->{$key} = ''; + } else { + delete $row->{$key} unless defined $row->{$key}; + } } push( @m, $row ); -- 2.39.5