summaryrefslogtreecommitdiffstats
path: root/Bugzilla/BugMail.pm
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-06-29 10:56:50 +0200
committerByron Jones <bjones@mozilla.com>2012-06-29 10:56:50 +0200
commit9327c8012e2440509b91dfa8791d9cd5db27afda (patch)
treec2f2f29a67ebee7f414f8b91da8f4295868c0178 /Bugzilla/BugMail.pm
parent07fccd2aa63b8597ab82845517e4b75e1f0452c0 (diff)
downloadbugzilla-9327c8012e2440509b91dfa8791d9cd5db27afda.tar.gz
bugzilla-9327c8012e2440509b91dfa8791d9cd5db27afda.tar.xz
Fix SQL error caused if a bugmail_recipients hook deletes all recipients
Diffstat (limited to 'Bugzilla/BugMail.pm')
-rw-r--r--Bugzilla/BugMail.pm30
1 files changed, 16 insertions, 14 deletions
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 2a70127f1..31a0a1af2 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -210,21 +210,23 @@ sub Send {
{ bug => $bug, recipients => \%recipients,
users => \%user_cache, diffs => \@diffs });
- # Find all those user-watching anyone on the current list, who is not
- # on it already themselves.
- my $involved = join(",", keys %recipients);
-
- my $userwatchers =
- $dbh->selectall_arrayref("SELECT watcher, watched FROM watch
- WHERE watched IN ($involved)");
-
- # Mark these people as having the role of the person they are watching
- foreach my $watch (@$userwatchers) {
- while (my ($role, $bits) = each %{$recipients{$watch->[1]}}) {
- $recipients{$watch->[0]}->{$role} |= BIT_WATCHING
- if $bits & BIT_DIRECT;
+ if (scalar keys %recipients) {
+ # Find all those user-watching anyone on the current list, who is not
+ # on it already themselves.
+ my $involved = join(",", keys %recipients);
+
+ my $userwatchers =
+ $dbh->selectall_arrayref("SELECT watcher, watched FROM watch
+ WHERE watched IN ($involved)");
+
+ # Mark these people as having the role of the person they are watching
+ foreach my $watch (@$userwatchers) {
+ while (my ($role, $bits) = each %{$recipients{$watch->[1]}}) {
+ $recipients{$watch->[0]}->{$role} |= BIT_WATCHING
+ if $bits & BIT_DIRECT;
+ }
+ push(@{$watching{$watch->[0]}}, $watch->[1]);
}
- push(@{$watching{$watch->[0]}}, $watch->[1]);
}
# Global watcher