From aa11ef5c0603f18fd5fdfdf921d1119f36573434 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 19 Jun 2015 20:27:23 +0000 Subject: Bug 1176368: backport upstream bug 1171813 to bmo/master to fix changing of voting value to auto confirm bugs --- extensions/Voting/Extension.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'extensions/Voting/Extension.pm') diff --git a/extensions/Voting/Extension.pm b/extensions/Voting/Extension.pm index 0ef79d3d3..39ed7c4b4 100644 --- a/extensions/Voting/Extension.pm +++ b/extensions/Voting/Extension.pm @@ -639,7 +639,7 @@ sub _update_votes { $sth_getVotes->execute($id); my $v = $sth_getVotes->fetchrow_array || 0; $sth_updateVotes->execute($v, $id); - $bugs{$id}->{votes} = $v; + $bugs{$id}->{votes} = $v if $bugs{$id}; my $confirmed = _confirm_if_vote_confirmed($bugs{$id} || $id); push (@updated_bugs, $id) if $confirmed; } @@ -750,7 +750,7 @@ sub _modify_bug_votes { my @updated_bugs; foreach my $bug_id (@$bug_list) { - my $confirmed = _confirm_if_vote_confirmed($bug_id); + my $confirmed = _confirm_if_vote_confirmed($bug_id, $product); push (@updated_bugs, $bug_id) if $confirmed; } $changes->{'_confirmed_bugs'} = \@updated_bugs; @@ -856,13 +856,14 @@ sub _remove_votes { # If a user votes for a bug, or the number of votes required to # confirm a bug has been reduced, check if the bug is now confirmed. sub _confirm_if_vote_confirmed { - my $id = shift; + my ($id, $product) = @_; my $bug = ref $id ? $id : new Bugzilla::Bug({ id => $id, cache => 1 }); + $product ||= $bug->product_obj; my $ret = 0; if (!$bug->everconfirmed - and $bug->product_obj->{votestoconfirm} - and $bug->votes >= $bug->product_obj->{votestoconfirm}) + and $product->{votestoconfirm} + and $bug->votes >= $product->{votestoconfirm}) { $bug->add_comment('', { type => CMT_POPULAR_VOTES }); -- cgit v1.2.3-24-g4f1b