]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 904467 - error when %recipients is empty (e.g. after bugmail_recipients empties it)
authorDamien Nozay <damien.nozay@gmail.com>
Mon, 13 Jan 2014 16:26:28 +0000 (11:26 -0500)
committerDave Lawrence <dlawrence@mozilla.com>
Mon, 13 Jan 2014 16:26:28 +0000 (11:26 -0500)
r/a=glob

Bugzilla/BugMail.pm

index 6c7be5e12b80470869c62d5d1b44c65de81f15be..48222fbf77deba803d22476ddfacf78a47e06b83 100644 (file)
@@ -186,21 +186,24 @@ 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;
+    # We should not assume %recipients to have any entries.
+    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