Bug 37881: Editing patron with guarantor won't crash
This patch fixes issue introduced by BZ32530 Test Plan (on main): 1 - Edit a patron 2 - Do not change anything and submit -> you get an error 3 - Apply both patches 4 - Repeat 1&2 -> everything works fine 5 - Try and delete the guarantor -> it will be deleted Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
4a12b7b858
commit
8d76a99d47
|
|
@ -934,17 +934,26 @@ sub add_guarantors {
|
|||
my @new_guarantor_id = $input->multi_param('new_guarantor_id');
|
||||
my @new_guarantor_relationship = $input->multi_param('new_guarantor_relationship');
|
||||
|
||||
for ( my $i = 0 ; $i < scalar @new_guarantor_id; $i++ ) {
|
||||
for ( my $i = 0 ; $i < scalar @new_guarantor_id ; $i++ ) {
|
||||
my $guarantor_id = $new_guarantor_id[$i];
|
||||
my $relationship = $new_guarantor_relationship[$i];
|
||||
|
||||
next unless $guarantor_id;
|
||||
|
||||
$patron->add_guarantor(
|
||||
my $existing_relationship_count = Koha::Patron::Relationships->search(
|
||||
{
|
||||
guarantee_id => $patron->id,
|
||||
guarantor_id => $guarantor_id,
|
||||
relationship => $relationship,
|
||||
}
|
||||
);
|
||||
)->count;
|
||||
|
||||
if ( $existing_relationship_count == 0 ) {
|
||||
$patron->add_guarantor(
|
||||
{
|
||||
guarantor_id => $guarantor_id,
|
||||
relationship => $relationship,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue