Bugzilla – Attachment 172948 Details for
Bug 35508
Update borrowers.updated_on when modifying a patron's attribute
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35508: Don't update patron attributes if new list of attributes matches list of existing attributes
Bug-35508-Dont-update-patron-attributes-if-new-lis.patch (text/plain), 3.81 KB, created by
Kyle M Hall (khall)
on 2024-10-18 10:50:11 UTC
(
hide
)
Description:
Bug 35508: Don't update patron attributes if new list of attributes matches list of existing attributes
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-10-18 10:50:11 UTC
Size:
3.81 KB
patch
obsolete
>From e812a0a9007a67df4b9b62d1aa1d96af3d7ec1e4 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 28 May 2024 13:26:03 -0400 >Subject: [PATCH] Bug 35508: Don't update patron attributes if new list of > attributes matches list of existing attributes > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Patron/Attribute.pm | 1 + > members/memberentry.pl | 44 +++++++++++++++++++++++++++++++++++++--- > 2 files changed, 42 insertions(+), 3 deletions(-) > >diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm >index 863d55850b0..93b25ece028 100644 >--- a/Koha/Patron/Attribute.pm >+++ b/Koha/Patron/Attribute.pm >@@ -58,6 +58,7 @@ sub store { > > Koha::Exceptions::Patron::Attribute::InvalidAttributeValue->throw( attribute => $self ) > unless $self->value_ok(); >+ > C4::Context->dbh->do( > "UPDATE borrowers SET updated_on = NOW() WHERE borrowernumber = ?", undef, > $self->borrowernumber >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 2227df425fb..6e35614268f 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -574,9 +574,47 @@ if ((!$nok) and $nodouble and ($op eq 'cud-insert' or $op eq 'cud-save')){ > > if ( $success ) { > if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { >- $patron->extended_attributes->filter_by_branch_limitations->delete; >- $patron->extended_attributes($extended_patron_attributes); >- } >+ my $existing_attributes = $patron->extended_attributes->filter_by_branch_limitations->unblessed; >+ >+ my $needs_update = 1; >+ >+ # If there are an unqueunal number of new and old patron attributes they definietely need updated >+ if ( scalar @{$existing_attributes} == scalar @{$extended_patron_attributes} ) { >+ my $seen = 0; >+ for ( my $i = 0 ; $i <= scalar @{$extended_patron_attributes} ; $i++ ) { >+ my $new_attr = $extended_patron_attributes->[$i]; >+ next unless $new_attr; >+ for ( my $j = 0 ; $j <= scalar @{$existing_attributes} ; $j++ ) { >+ my $existing_attr = $existing_attributes->[$j]; >+ next unless $existing_attr; >+ >+ if ( $new_attr->{attribute} eq $existing_attr->{attribute} >+ && $new_attr->{borrowernumber} eq $existing_attr->{borrowernumber} >+ && $new_attr->{code} eq $existing_attr->{code} ) >+ { >+ $seen++; >+ >+ # Remove the match from the "old" attribute >+ splice( @{$existing_attributes}, $j, 1 ); >+ >+ # Move on to look at the next "new" attribute >+ last; >+ } >+ } >+ } >+ >+ # If we found a match for each existing attribute and the number of see attributes matches the number seen >+ # we don't need to update the attributes >+ if ( scalar @{$existing_attributes} == 0 && $seen == @{$extended_patron_attributes} ) { >+ $needs_update = 0; >+ } >+ } >+ >+ if ($needs_update) { >+ $patron->extended_attributes->filter_by_branch_limitations->delete; >+ $patron->extended_attributes($extended_patron_attributes); >+ } >+ } > > if ( $destination eq 'circ' and not C4::Auth::haspermission( C4::Context->userenv->{id}, { circulate => 'circulate_remaining_permissions' } ) ) { > # If we want to redirect to circulation.pl and need to check if the logged in user has the necessary permission >-- >2.39.5 (Apple Git-154)
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 35508
:
159838
|
159895
|
165012
|
165013
|
166640
|
166641
|
167229
|
172946
|
172947
| 172948 |
172949