Bug 20443: Fix patron modification approval

There was a mismatch between "value" and "attribute". Before this
patchset, "value" was sometimes used, but then it comes "attribute" to
match the DB column's name.
We must keep both here, when an upgrade is done we could have "value"
that is still in the borrower_modifications.extended_attributes JSON

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2020-03-09 11:43:14 +01:00 committed by Martin Renvoize
parent 994ea386c3
commit ea5e9f25e9
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 7 additions and 6 deletions

View File

@ -131,17 +131,18 @@ sub approve {
);
}
foreach my $attr ( @{$extended_attributes} ) {
$attr->{attribute} = exists $attr->{attribute} ? $attr->{attribute} : $attr->{value};
Koha::Patron::Attribute->new(
{ borrowernumber => $patron->borrowernumber,
code => $attr->{code},
attribute => $attr->{value}
attribute => $attr->{attribute},
}
)->store
if $attr->{value} # there's a value
if $attr->{attribute} # there's a value
or
( defined $attr->{value} # there's a value that is 0, and not
&& $attr->{value} ne "" # the empty string which means delete
&& $attr->{value} == 0
( defined $attr->{attribute} # there's a value that is 0, and not
&& $attr->{attribute} ne "" # the empty string which means delete
&& $attr->{attribute} == 0
);
}
}

View File

@ -131,7 +131,7 @@ sub pending {
Koha::Patron::Attribute->new(
{ borrowernumber => $row->{borrowernumber},
code => $attr->{code},
attribute => $attr->{value}
attribute => exists $attr->{attribute} ? $attr->{attribute} : $attr->{value},
}
);
}