Bugzilla – Attachment 91616 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: Tweak to use the new database structure
Bug-23151-Tweak-to-use-the-new-database-structure.patch (text/plain), 4.03 KB, created by
Marcel de Rooy
on 2019-07-19 08:06:30 UTC
(
hide
)
Description:
Bug 23151: Tweak to use the new database structure
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2019-07-19 08:06:30 UTC
Size:
4.03 KB
patch
obsolete
>From 85f408a28b2f602da7de0899ad6720ea638acfe3 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 19 Jun 2019 16:29:59 +0000 >Subject: [PATCH] Bug 23151: Tweak to use the new database structure >Content-Type: text/plain; charset=utf-8 > >This will use changed_fields to know whether a >borrower field is actually modified. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Patron/Modification.pm | 16 ++++++++-------- > Koha/Patron/Modifications.pm | 10 +++++++--- > opac/opac-memberentry.pl | 4 ++-- > 3 files changed, 17 insertions(+), 13 deletions(-) > >diff --git a/Koha/Patron/Modification.pm b/Koha/Patron/Modification.pm >index b5d5aded70..1e577b164f 100644 >--- a/Koha/Patron/Modification.pm >+++ b/Koha/Patron/Modification.pm >@@ -28,7 +28,7 @@ use Koha::Patron::Attributes; > use Koha::Patron::Modifications; > > use JSON; >-use List::MoreUtils qw( uniq ); >+use List::MoreUtils qw( uniq any ); > use Try::Tiny; > > use base qw(Koha::Object); >@@ -91,17 +91,17 @@ sub approve { > delete $data->{timestamp}; > delete $data->{verification_token}; > delete $data->{extended_attributes}; >+ my $changed_fields = $data->{changed_fields}; >+ delete $data->{changed_fields}; > > 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}; >+ my @keep_keys = split /,/, $changed_fields; >+ my @all_keys = keys %$data; >+ foreach my $key ( @all_keys ) { >+ next if (any { $_ eq $key } @keep_keys); >+ delete $data->{$key}; > } > > $patron->set($data); >diff --git a/Koha/Patron/Modifications.pm b/Koha/Patron/Modifications.pm >index 646d112f4c..e29079ca2e 100644 >--- a/Koha/Patron/Modifications.pm >+++ b/Koha/Patron/Modifications.pm >@@ -30,6 +30,7 @@ use Koha::Patron::Attribute; > use Koha::Patron::Modification; > > use JSON; >+use List::Util qw /any none/; > > use base qw(Koha::Objects); > >@@ -116,7 +117,12 @@ sub pending { > > my @m; > while ( my $row = $sth->fetchrow_hashref() ) { >+ my @changed_keys = split /,/, $row->{changed_fields}; > foreach my $key ( keys %$row ) { >+ if ($key eq 'changed_fields') { >+ delete $row->{$key}; >+ next; >+ } > if ( defined $row->{$key} && $key eq 'extended_attributes' ) { > my $attributes = from_json( $row->{$key} ); > my @pending_attributes; >@@ -132,9 +138,7 @@ sub pending { > > $row->{$key} = \@pending_attributes; > } >- if ( $key eq 'dateofbirth' and not defined $row->{$key}) { >- $row->{$key} = ''; >- } else { >+ if (none { $_ eq $key } @changed_keys) { > delete $row->{$key} unless defined $row->{$key}; > } > } >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index f76a30c098..db8a6acbef 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -247,9 +247,8 @@ elsif ( $action eq 'update' ) { > my %borrower = ParseCgiForBorrower($cgi); > $borrower{borrowernumber} = $borrowernumber; > >- my %borrower_changes = DelEmptyFields(%borrower); > my @empty_mandatory_fields = >- CheckMandatoryFields( \%borrower_changes, $action ); >+ CheckMandatoryFields( \%borrower, $action ); > my $invalidformfields = CheckForInvalidFields(\%borrower); > > # Send back the data to the template >@@ -270,6 +269,7 @@ elsif ( $action eq 'update' ) { > } > else { > my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower ); >+ $borrower_changes{'changed_fields'} = join ',', keys %borrower_changes; > my $extended_attributes_changes = FilterUnchangedAttributes( $borrowernumber, $attributes ); > > if ( %borrower_changes || scalar @{$extended_attributes_changes} > 0 ) { >-- >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