Bugzilla – Attachment 90797 Details for
Bug 23151
Patron self modification sends null dateofbirth
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23151: Properly clear/not clear date of birth.
Bug-23151-Properly-clearnot-clear-date-of-birth.patch (text/plain), 4.25 KB, created by
Lucas Gass (lukeg)
on 2019-06-19 15:02:21 UTC
(
hide
)
Description:
Bug 23151: Properly clear/not clear date of birth.
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2019-06-19 15:02:21 UTC
Size:
4.25 KB
patch
obsolete
>From 47fdbc81b7b5120524072938c8b3dcd493c76a1b Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 19 Jun 2019 01:32:22 +0000 >Subject: [PATCH] Bug 23151: Properly clear/not clear date of birth. > >The problem is caused by how change is stored: {changed value} || NULL. >NULL means no change, but in the case of clearing a date of birth >one wants to set it to NULL, which is indistinguishable from the >no change value. > >By adding a DUMMY_DATE '9999-12-31', and using it as an intermediate >check, we can set the value to NULL. This required storing the >DUMMY_DATE as the change value, then in the case of date of birth >displaying blank when listing the changes, and saving undef when >the changes are stored. > >TEST PLAN >--------- >0) running this test plan without the patch results in bad data. >1) Ensure the Global System Preference OPACPatronDetails is set to Allow. >2) reset_all in the kohadevbox. >3) log into admin/admin. >4) open up localhost:8080 in one tab, and localhost:8081 in another. >5) In the opac tab, click on the user name, and then the 'your personal >details' tab. >5a) Set the first name, so it won't complain. >6) Set the salutation to Mr. and the birth date to any date. >7) scroll down and submit >8) In the staff tab, click home >9) click on the 'patrons requesting modifications' at the bottom of the screen. >-- you should see the changes you just made. >10) click the 'Approve' radio button, and click Submit. >11) In the opac tab, click on the 'your personal details' tab. >-- the values should be as expected >12) Set the salutation to blank and leave the birth date alone. >13) scroll down and submit >14) repeat steps 8-11. >-- the values should be as expected >15) Clear the birth date >16) scroll down and submit >17) repeat steps 8-11. >18) Set the salutation to Mr. and leave the birth date blank. >19) scroll down and submit. >20) repeat steps 8-11. >21) Repeat steps 6-11 for good measure. > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > Koha/Patron/Modification.pm | 10 +++++----- > Koha/Patron/Modifications.pm | 3 ++- > opac/opac-memberentry.pl | 3 +++ > 3 files changed, 10 insertions(+), 6 deletions(-) > >diff --git a/Koha/Patron/Modification.pm b/Koha/Patron/Modification.pm >index b5d5aded70..824a8940e2 100644 >--- a/Koha/Patron/Modification.pm >+++ b/Koha/Patron/Modification.pm >@@ -33,6 +33,8 @@ use Try::Tiny; > > use base qw(Koha::Object); > >+our $DUMMY_DATE = '9999-12-31'; >+ > =head1 NAME > > Koha::Patron::Modification - Class represents a request to modify or create a patron >@@ -96,12 +98,10 @@ sub approve { > 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}; >+ if ($data->{$key} == $Koha::Patron::Modification::DUMMY_DATE) { >+ $data->{$key} = undef; >+ } > } > > $patron->set($data); >diff --git a/Koha/Patron/Modifications.pm b/Koha/Patron/Modifications.pm >index 646d112f4c..084376fb6a 100644 >--- a/Koha/Patron/Modifications.pm >+++ b/Koha/Patron/Modifications.pm >@@ -33,6 +33,7 @@ use JSON; > > use base qw(Koha::Objects); > >+ > =head2 pending_count > > $count = Koha::Patron::Modifications->pending_count(); >@@ -132,7 +133,7 @@ sub pending { > > $row->{$key} = \@pending_attributes; > } >- if ( $key eq 'dateofbirth' and not defined $row->{$key}) { >+ if ( $key eq 'dateofbirth' and $row->{$key} == $Koha::Patron::Modification::DUMMY_DATE) { > $row->{$key} = ''; > } else { > delete $row->{$key} unless defined $row->{$key}; >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index 7fc9226c29..e92bda50cb 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -247,6 +247,9 @@ elsif ( $action eq 'update' ) { > my %borrower = ParseCgiForBorrower($cgi); > $borrower{borrowernumber} = $borrowernumber; > >+ if (defined $borrower->{dateofbirth} && ! $borrower{dateofbirth}) { >+ $borrower{dateofbirth} = $Koha::Patron::Modification::DUMMY_DATE; >+ } > my %borrower_changes = DelEmptyFields(%borrower); > my @empty_mandatory_fields = > CheckMandatoryFields( \%borrower_changes, $action ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23151
:
90764
|
90769
|
90795
|
90796
|
90797
|
90798
|
90799
|
90805
|
90806
|
90807
|
90808
|
90809
|
91070
|
91071
|
91072
|
91073
|
91074
|
91075
|
91076
|
91614
|
91615
|
91616
|
91617
|
91618
|
91619
|
91620