mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 22:35:43 +00:00
Bug 328449: Remove BugMail::MessageToMTA() from Bug::RemoveVotes() - Patch by Fr�d�ric Buclin <LpSolit@gmail.com> r=mkanat a=myk
This commit is contained in:
parent
e282be3a75
commit
da82009a4a
@ -38,7 +38,6 @@ use vars qw($legal_keywords @legal_platform
|
||||
use CGI::Carp qw(fatalsToBrowser);
|
||||
|
||||
use Bugzilla::Attachment;
|
||||
use Bugzilla::BugMail;
|
||||
use Bugzilla::Config;
|
||||
use Bugzilla::Constants;
|
||||
use Bugzilla::Field;
|
||||
@ -1019,6 +1018,11 @@ sub RemoveVotes {
|
||||
while (my ($name, $userid, $oldvotes, $votesperuser, $maxvotesperbug) = $sth->fetchrow_array()) {
|
||||
push(@list, [$name, $userid, $oldvotes, $votesperuser, $maxvotesperbug]);
|
||||
}
|
||||
|
||||
# @messages stores all emails which have to be sent, if any.
|
||||
# This array is passed to the caller which will send these emails itself.
|
||||
my @messages = ();
|
||||
|
||||
if (scalar(@list)) {
|
||||
foreach my $ref (@list) {
|
||||
my ($name, $userid, $oldvotes, $votesperuser, $maxvotesperbug) = (@$ref);
|
||||
@ -1079,7 +1083,7 @@ sub RemoveVotes {
|
||||
$substs{"count"} = $removedvotes . "\n " . $newvotestext;
|
||||
|
||||
my $msg = perform_substs(Param("voteremovedmail"), \%substs);
|
||||
Bugzilla::BugMail::MessageToMTA($msg);
|
||||
push(@messages, $msg);
|
||||
}
|
||||
my $votes = $dbh->selectrow_array("SELECT SUM(vote_count) " .
|
||||
"FROM votes WHERE bug_id = ?",
|
||||
@ -1087,6 +1091,8 @@ sub RemoveVotes {
|
||||
$dbh->do("UPDATE bugs SET votes = ? WHERE bug_id = ?",
|
||||
undef, ($votes, $id));
|
||||
}
|
||||
# Now return the array containing emails to be sent.
|
||||
return \@messages;
|
||||
}
|
||||
|
||||
# If a user votes for a bug, or the number of votes required to
|
||||
|
@ -23,7 +23,7 @@
|
||||
# Dawn Endico <endico@mozilla.org>
|
||||
# Joe Robins <jmrobins@tgix.com>
|
||||
# Gavin Shelley <bugzilla@chimpychompy.org>
|
||||
# Fr<EFBFBD><EFBFBD>ic Buclin <LpSolit@gmail.com>
|
||||
# Frédéric Buclin <LpSolit@gmail.com>
|
||||
# Greg Hendricks <ghendricks@novell.com>
|
||||
# Lance Larsh <lance.larsh@oracle.com>
|
||||
#
|
||||
@ -39,6 +39,7 @@ require "globals.pl";
|
||||
use Bugzilla::Bug;
|
||||
use Bugzilla::Series;
|
||||
use Bugzilla::Config qw(:DEFAULT $datadir);
|
||||
use Bugzilla::BugMail;
|
||||
use Bugzilla::Product;
|
||||
use Bugzilla::Classification;
|
||||
use Bugzilla::Milestone;
|
||||
@ -899,9 +900,15 @@ if ($action eq 'update') {
|
||||
|
||||
foreach my $vote (@$votes) {
|
||||
my ($who, $id) = (@$vote);
|
||||
RemoveVotes($id, $who, "The rules for voting on this product " .
|
||||
"has changed;\nyou had too many votes " .
|
||||
"for a single bug.");
|
||||
# If some votes are removed, RemoveVotes() returns a list
|
||||
# of messages to send to voters.
|
||||
my $msgs =
|
||||
RemoveVotes($id, $who, "The rules for voting on this product " .
|
||||
"has changed;\nyou had too many votes " .
|
||||
"for a single bug.");
|
||||
foreach my $msg (@$msgs) {
|
||||
Bugzilla::BugMail::MessageToMTA($msg);
|
||||
}
|
||||
my $name = DBID_to_name($who);
|
||||
|
||||
push(@toomanyvotes_list,
|
||||
@ -945,10 +952,16 @@ if ($action eq 'update') {
|
||||
undef, ($product->id, $who));
|
||||
|
||||
foreach my $bug_id (@$bug_ids) {
|
||||
RemoveVotes($bug_id, $who, "The rules for voting on this " .
|
||||
"product has changed; you had " .
|
||||
"too many\ntotal votes, so all " .
|
||||
"votes have been removed.");
|
||||
# RemoveVotes() returns a list of messages to send
|
||||
# in case some voters had too many votes.
|
||||
my $msgs =
|
||||
RemoveVotes($bug_id, $who, "The rules for voting on this " .
|
||||
"product has changed; you had " .
|
||||
"too many\ntotal votes, so all " .
|
||||
"votes have been removed.");
|
||||
foreach my $msg (@$msgs) {
|
||||
Bugzilla::BugMail::MessageToMTA($msg);
|
||||
}
|
||||
my $name = DBID_to_name($who);
|
||||
|
||||
push(@toomanytotalvotes_list,
|
||||
|
@ -1960,7 +1960,10 @@ foreach my $id (@idlist) {
|
||||
#
|
||||
my $origOwner = "";
|
||||
my $origQaContact = "";
|
||||
|
||||
|
||||
# $msgs will store emails which have to be sent to voters, if any.
|
||||
my $msgs;
|
||||
|
||||
foreach my $c (@::log_columns) {
|
||||
my $col = $c; # We modify it, don't want to modify array
|
||||
# values in place.
|
||||
@ -2004,10 +2007,13 @@ foreach my $id (@idlist) {
|
||||
}
|
||||
|
||||
if ($col eq 'product') {
|
||||
RemoveVotes($id, 0,
|
||||
"This bug has been moved to a different product");
|
||||
# If some votes have been removed, RemoveVotes() returns
|
||||
# a list of messages to send to voters.
|
||||
# We delay the sending of these messages till tables are unlocked.
|
||||
$msgs = RemoveVotes($id, 0,
|
||||
"This bug has been moved to a different product");
|
||||
}
|
||||
|
||||
|
||||
if ($col eq 'bug_status'
|
||||
&& IsOpenedState($old) ne IsOpenedState($new))
|
||||
{
|
||||
@ -2026,6 +2032,11 @@ foreach my $id (@idlist) {
|
||||
}
|
||||
$dbh->bz_unlock_tables();
|
||||
|
||||
# Now is a good time to send email to voters.
|
||||
foreach my $msg (@$msgs) {
|
||||
Bugzilla::BugMail::MessageToMTA($msg);
|
||||
}
|
||||
|
||||
if ($duplicate) {
|
||||
# Check to see if Reporter of this bug is reporter of Dupe
|
||||
SendSQL("SELECT reporter FROM bugs WHERE bug_id = " .
|
||||
|
Loading…
Reference in New Issue
Block a user