Commit 10ad2870 authored by dmose%mozilla.org's avatar dmose%mozilla.org

fix for bug found in original 17464 patch, where removal from the CC list was…

fix for bug found in original 17464 patch, where removal from the CC list was not generating a mail. r=donm@bluemartini.com
parent 7e06172f
...@@ -398,6 +398,7 @@ ConnectToDatabase(); ...@@ -398,6 +398,7 @@ ConnectToDatabase();
my $formCcSet = new RelationSet; my $formCcSet = new RelationSet;
my $origCcSet = new RelationSet; my $origCcSet = new RelationSet;
my $origCcString; my $origCcString;
my $removedCcString = "";
# We make sure to check out the CC list before we actually start touching any # We make sure to check out the CC list before we actually start touching any
# bugs. mergeFromString() ultimately searches the database using a quoted # bugs. mergeFromString() ultimately searches the database using a quoted
...@@ -409,6 +410,11 @@ if (defined $::FORM{'newcc'} && defined $::FORM{'id'}) { ...@@ -409,6 +410,11 @@ if (defined $::FORM{'newcc'} && defined $::FORM{'id'}) {
$formCcSet->mergeFromDB("select who from cc where bug_id = $::FORM{'id'}"); $formCcSet->mergeFromDB("select who from cc where bug_id = $::FORM{'id'}");
$origCcString = $origCcSet->toString(); # cache a copy of the string vers $origCcString = $origCcSet->toString(); # cache a copy of the string vers
if ((exists $::FORM{'removecc'}) && (exists $::FORM{'cc'})) { if ((exists $::FORM{'removecc'}) && (exists $::FORM{'cc'})) {
# save off the folks removed from the CC list so they can be given to
# the processmaill command line so they can be sent mail about it.
#
$removedCcString = join (',', @{$::MFORM{'cc'}});
$formCcSet->removeItemsInArray(@{$::MFORM{'cc'}}); $formCcSet->removeItemsInArray(@{$::MFORM{'cc'}});
} }
$formCcSet->mergeFromString($::FORM{'newcc'}); $formCcSet->mergeFromString($::FORM{'newcc'});
...@@ -896,6 +902,12 @@ The changes made were: ...@@ -896,6 +902,12 @@ The changes made were:
# #
my @newvalues = SnapShotBug($id); my @newvalues = SnapShotBug($id);
# for passing to processmail to ensure that when someone is removed
# from one of these fields, they get notified of that fact (if desired)
#
my $origOwner = "";
my $origQaContact = "";
foreach my $c (@::log_columns) { foreach my $c (@::log_columns) {
my $col = $c; # We modify it, don't want to modify array my $col = $c; # We modify it, don't want to modify array
# values in place. # values in place.
...@@ -908,13 +920,24 @@ The changes made were: ...@@ -908,13 +920,24 @@ The changes made were:
$new = ""; $new = "";
} }
if ($old ne $new) { if ($old ne $new) {
if ($col eq 'assigned_to' || $col eq 'qa_contact') {
# save off the old value for passing to processmail so the old
# owner can be notified
#
if ($col eq 'assigned_to') {
$old = ($old) ? DBID_to_name($old) : ""; $old = ($old) ? DBID_to_name($old) : "";
$new = ($new) ? DBID_to_name($new) : ""; $new = ($new) ? DBID_to_name($new) : "";
$origCcString .= ",$old"; # make sure to send mail to people $origOwner = $old;
# if they are going to no longer get
# updates about this bug.
} }
# ditto for the old qa contact
#
if ($col eq 'qa_contact') {
$old = ($old) ? DBID_to_name($old) : "";
$new = ($new) ? DBID_to_name($new) : "";
$origQaContact = $old;
}
if ($col eq 'product') { if ($col eq 'product') {
RemoveVotes($id, 0, RemoveVotes($id, 0,
"This bug has been moved to a different product"); "This bug has been moved to a different product");
...@@ -930,7 +953,20 @@ The changes made were: ...@@ -930,7 +953,20 @@ The changes made were:
print "<TABLE BORDER=1><TD><H2>Changes to bug $id submitted</H2>\n"; print "<TABLE BORDER=1><TD><H2>Changes to bug $id submitted</H2>\n";
SendSQL("unlock tables"); SendSQL("unlock tables");
system("./processmail", "-forcecc", $origCcString, $id, $::FORM{'who'});
my @ARGLIST = ("./processmail");
if ( $removedCcString ne "" ) {
push @ARGLIST, ("-forcecc", $removedCcString);
}
if ( $origOwner ne "" ) {
push @ARGLIST, ("-forceowner", $origOwner);
}
if ( $origQaContact ne "") {
push @ARGLIST, ( "-forceqacontact", $origQaContact);
}
push @ARGLIST, ($id, $::FORM{'who'});
system @ARGLIST;
print "<TD><A HREF=\"show_bug.cgi?id=$id\">Back To BUG# $id</A></TABLE>\n"; print "<TD><A HREF=\"show_bug.cgi?id=$id\">Back To BUG# $id</A></TABLE>\n";
foreach my $k (keys(%dependencychanged)) { foreach my $k (keys(%dependencychanged)) {
......
...@@ -46,7 +46,11 @@ my @excludedAddresses = (); ...@@ -46,7 +46,11 @@ my @excludedAddresses = ();
# disable email flag for offline debugging work # disable email flag for offline debugging work
my $enableSendMail = 1; my $enableSendMail = 1;
my @forcecc; my %force;
@{$force{'QAcontact'}} = ();
@{$force{'Owner'}} = ();
@{$force{'Reporter'}} = ();
@{$force{'CClist'}} = ();
sub Lock { sub Lock {
if ($::lockcount <= 0) { if ($::lockcount <= 0) {
...@@ -552,7 +556,7 @@ sub NewProcessOneBug { ...@@ -552,7 +556,7 @@ sub NewProcessOneBug {
my @personlist = ($values{'assigned_to'}, $values{'reporter'}, my @personlist = ($values{'assigned_to'}, $values{'reporter'},
split(/,/, $values{'cc'}), split(/,/, $values{'cc'}),
@voterlist, @voterlist,
@forcecc); $force{'CClist'});
if ($values{'qa_contact'}) { push @personlist, $values{'qa_contact'} } if ($values{'qa_contact'}) { push @personlist, $values{'qa_contact'} }
for my $person (@personlist) { for my $person (@personlist) {
$count++; $count++;
...@@ -715,6 +719,11 @@ sub filterEmailGroup ($$$) { ...@@ -715,6 +719,11 @@ sub filterEmailGroup ($$$) {
my @emailList = split(/,/,$emailList); my @emailList = split(/,/,$emailList);
my @filteredList = (); my @filteredList = ();
# the force list for this email group needs to be checked as well
#
push @emailList, @{$force{$emailGroup}};
foreach my $person (@emailList) { foreach my $person (@emailList) {
my $userid; my $userid;
...@@ -763,6 +772,13 @@ sub filterEmailGroup ($$$) { ...@@ -763,6 +772,13 @@ sub filterEmailGroup ($$$) {
} }
else { else {
# the 255 param is here, because without a third param,
# split will trim any trailing null fields, which causes perl
# to eject lots of warnings. any suitably large number would
# do.
my %userFlags = split(/~/, $userFlagString, 255);
# The default condition is to send each person email. # The default condition is to send each person email.
# If we match the email attribute with the user flag, and # If we match the email attribute with the user flag, and
# they do not want email, then remove them from the list. # they do not want email, then remove them from the list.
...@@ -773,19 +789,13 @@ sub filterEmailGroup ($$$) { ...@@ -773,19 +789,13 @@ sub filterEmailGroup ($$$) {
my $matchName = 'email' . $emailGroup . $attribute; my $matchName = 'email' . $emailGroup . $attribute;
# the 255 param is here, because without a third param,
# split will trim any trailing null fields, which causes perl
# to eject lots of warnings. any suitably large number would
# do.
my %userFlags = split(/~/, $userFlagString, 255);
while ((my $flagName, my $flagValue) = each %userFlags) { while ((my $flagName, my $flagValue) = each %userFlags) {
if ($flagName !~ /$emailGroup/) { next; } if ($flagName !~ /$emailGroup/) {
next;
}
if ( $flagName eq $matchName if ( $flagName eq $matchName && $flagValue ne 'on') {
&& $flagValue ne 'on') {
pop(@filteredList); pop(@filteredList);
} }
...@@ -793,12 +803,38 @@ sub filterEmailGroup ($$$) { ...@@ -793,12 +803,38 @@ sub filterEmailGroup ($$$) {
} # for each email attribute } # for each email attribute
} # if $userFlagString is valid # check to see if the person was removed from this email
# group.
# If email was not sent to the person, then put on excluded if ( grep ($_ eq $person, @{$force{$emailGroup}} ) ) {
# addresses list.
# if so, see if they want mail about that
#
if ( $userFlags{'email' . $emailGroup . 'Removeme'} eq 'on' ) {
# we definitely want mail sent to this person, since
# inclusion on a mail takes precedence over the previous
# exclusion
# have they been filtered for some other reason?
#
if (@filteredList == $lastCount) { if (@filteredList == $lastCount) {
# if so, put them back
#
push (@filteredList, $person);
}
}
}
} # if $userFlagString is valid
# has the person been moved off the filtered list?
#
if (@filteredList == $lastCount ) {
# mark them as excluded
#
push (@excludedAddresses,$person); push (@excludedAddresses,$person);
} }
...@@ -980,7 +1016,8 @@ sub ProcessOneBug { ...@@ -980,7 +1016,8 @@ sub ProcessOneBug {
foreach my $v (split(/,/, "$::bug{'cclist'},$::bug{'voterlist'}")) { foreach my $v (split(/,/, "$::bug{'cclist'},$::bug{'voterlist'}")) {
push @combinedcc, $v; push @combinedcc, $v;
} }
push (@combinedcc, (@forcecc)); push (@combinedcc, (@{$force{'CClist'}}, @{$force{'QAcontact'}},
@{$force{'Reporter'}}, @{$force{'Owner'}}));
my $cclist = fixaddresses("cc", \@combinedcc); my $cclist = fixaddresses("cc", \@combinedcc);
my $logstr = "Bug $i $verb"; my $logstr = "Bug $i $verb";
if ($tolist ne "" || $cclist ne "") { if ($tolist ne "" || $cclist ne "") {
...@@ -1094,12 +1131,25 @@ if ($#ARGV >= 0 && $ARGV[0] eq "regenerate") { ...@@ -1094,12 +1131,25 @@ if ($#ARGV >= 0 && $ARGV[0] eq "regenerate") {
if ($#ARGV >= 0 && $ARGV[0] eq "-forcecc") { if ($#ARGV >= 0 && $ARGV[0] eq "-forcecc") {
shift(@ARGV); shift(@ARGV);
foreach my $i (split(/,/, shift(@ARGV))) { foreach my $i (split(/,/, shift(@ARGV))) {
push(@forcecc, trim($i)); push(@{$force{'CClist'}}, trim($i));
} }
} }
if ($#ARGV >= 0 && $ARGV[0] eq "-forceowner") {
shift(@ARGV);
@{$force{'Owner'}} = (trim(shift(@ARGV)));
}
if ($#ARGV >= 0 && $ARGV[0] eq "-forceqacontact") {
shift(@ARGV);
@{$force{'QAcontact'}} = (trim(shift(@ARGV)));
}
if (($#ARGV < 0) || ($#ARGV > 1)) { if (($#ARGV < 0) || ($#ARGV > 1)) {
print "Usage error: processmail {bugid} {nametoexclude}\nOr: processmail regenerate\n"; print "Usage:\n processmail {bugid} {nametoexclude} " .
"[-forcecc list,of,users]\n [-forceowner name] " .
"[-forceqacontact name]\nor\n processmail regenerate\nor\n" .
" processmail rescanall\n";
exit; exit;
} }
......
...@@ -49,6 +49,7 @@ my @emailGroups = ( ...@@ -49,6 +49,7 @@ my @emailGroups = (
); );
my @emailFlags = ( my @emailFlags = (
'Removeme', 'If I am removed from that capacity',
'Comments', 'New Comments', 'Comments', 'New Comments',
'Attachments', 'New Attachments', 'Attachments', 'New Attachments',
'Status', 'Priority, status, severity, and milestone changes', 'Status', 'Priority, status, severity, and milestone changes',
...@@ -60,6 +61,7 @@ my @emailFlags = ( ...@@ -60,6 +61,7 @@ my @emailFlags = (
my $defaultEmailFlagString = my $defaultEmailFlagString =
'emailOwnerRemoveme~' . 'on~' .
'emailOwnerComments~' . 'on~' . 'emailOwnerComments~' . 'on~' .
'emailOwnerAttachments~' . 'on~' . 'emailOwnerAttachments~' . 'on~' .
'emailOwnerStatus~' . 'on~' . 'emailOwnerStatus~' . 'on~' .
...@@ -68,6 +70,7 @@ my $defaultEmailFlagString = ...@@ -68,6 +70,7 @@ my $defaultEmailFlagString =
'emailOwnerCC~' . 'on~' . 'emailOwnerCC~' . 'on~' .
'emailOwnerOther~' . 'on~' . 'emailOwnerOther~' . 'on~' .
'emailReporterRemoveme~' . 'on~' .
'emailReporterComments~' . 'on~' . 'emailReporterComments~' . 'on~' .
'emailReporterAttachments~' . 'on~' . 'emailReporterAttachments~' . 'on~' .
'emailReporterStatus~' . 'on~' . 'emailReporterStatus~' . 'on~' .
...@@ -76,6 +79,7 @@ my $defaultEmailFlagString = ...@@ -76,6 +79,7 @@ my $defaultEmailFlagString =
'emailReporterCC~' . 'on~' . 'emailReporterCC~' . 'on~' .
'emailReporterOther~' . 'on~' . 'emailReporterOther~' . 'on~' .
'emailQAcontactRemoveme~' . 'on~' .
'emailQAcontactComments~' . 'on~' . 'emailQAcontactComments~' . 'on~' .
'emailQAcontactAttachments~' . 'on~' . 'emailQAcontactAttachments~' . 'on~' .
'emailQAcontactStatus~' . 'on~' . 'emailQAcontactStatus~' . 'on~' .
...@@ -84,6 +88,7 @@ my $defaultEmailFlagString = ...@@ -84,6 +88,7 @@ my $defaultEmailFlagString =
'emailQAcontactCC~' . 'on~' . 'emailQAcontactCC~' . 'on~' .
'emailQAcontactOther~' . 'on~' . 'emailQAcontactOther~' . 'on~' .
'emailCClistRemoveme~' . 'on~' .
'emailCClistComments~' . 'on~' . 'emailCClistComments~' . 'on~' .
'emailCClistAttachments~' . 'on~' . 'emailCClistAttachments~' . 'on~' .
'emailCClistStatus~' . 'on~' . 'emailCClistStatus~' . 'on~' .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment