From 83dfa7353aac7df35f96fd9f024517460540d503 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 9 Mar 2020 11:43:14 +0100 Subject: [PATCH] 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 --- Koha/Patron/Modification.pm | 11 ++++++----- Koha/Patron/Modifications.pm | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Koha/Patron/Modification.pm b/Koha/Patron/Modification.pm index 63100e72bd..51f182a80b 100644 --- a/Koha/Patron/Modification.pm +++ b/Koha/Patron/Modification.pm @@ -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 ); } } diff --git a/Koha/Patron/Modifications.pm b/Koha/Patron/Modifications.pm index e29079ca2e..1ca0ab1163 100644 --- a/Koha/Patron/Modifications.pm +++ b/Koha/Patron/Modifications.pm @@ -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}, } ); } -- 2.20.1