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> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
4624425bf8
commit
eed4b0940d
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -592,9 +592,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
|
||||
|
|
|
|||
Loading…
Reference in New Issue