Bugzilla – Attachment 90807 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), 3.88 KB, created by
Mark Tompsett
on 2019-06-19 16:37:18 UTC
(
hide
)
Description:
Bug 23151: Tweak to use the new database structure
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2019-06-19 16:37:18 UTC
Size:
3.88 KB
patch
obsolete
>From d220eaa4f8fec9b67ddfbbc2c31ca9f26bae41a2 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 > >This will use changed_fields to know whether a >borrower field is actually modified. >--- > 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 7fc9226c29..6e37a01ce6 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