From 7f9a841d4ceeb5b6bb1648c702c2c753b1d75a51 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 14 Jul 2006 04:55:43 +0000 Subject: Bug 343338: Eliminate "my" variables from the root level of modules Patch By Max Kanat-Alexander r=LpSolit, a=myk --- Bugzilla/BugMail.pm | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'Bugzilla/BugMail.pm') diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index ddcf4791e..3597b3f46 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -49,25 +49,28 @@ use constant BIT_WATCHING => 2; # We need these strings for the X-Bugzilla-Reasons header # Note: this hash uses "," rather than "=>" to avoid auto-quoting of the LHS. -my %rel_names = (REL_ASSIGNEE , "AssignedTo", - REL_REPORTER , "Reporter", - REL_QA , "QAcontact", - REL_CC , "CC", - REL_VOTER , "Voter"); - -# This code is really ugly. It was a commandline interface, then it was moved. -# This really needs to be cleaned at some point. - -my %nomail; - -# This is run when we load the package -if (open(NOMAIL, '<', bz_locations->{'datadir'} . "/nomail")) { - while () { - $nomail{trim($_)} = 1; +use constant REL_NAMES => { + REL_ASSIGNEE, "AssignedTo", + REL_REPORTER, "Reporter", + REL_QA , "QAcontact", + REL_CC , "CC", + REL_VOTER , "Voter" +}; + +sub _read_nomail { + my $nomail = Bugzilla->request_cache->{bugmail_nomail}; + return $nomail if $nomail; + if (open(NOMAIL, '<', bz_locations->{'datadir'} . "/nomail")) { + while () { + $nomail->{trim($_)} = 1; + } + close(NOMAIL); } - close(NOMAIL); + Bugzilla->request_cache->{bugmail_nomail} = $nomail; + return $nomail; } + sub FormatTriple { my ($a, $b, $c) = (@_); $^A = ""; @@ -462,7 +465,8 @@ sub ProcessOneBug { # Make sure the user isn't in the nomail list, and the insider and # dep checks passed. - if ((!$nomail{$user->login}) && + my $nomail = _read_nomail(); + if ((!$nomail->{$user->login}) && $insider_ok && $dep_ok) { @@ -625,8 +629,8 @@ sub sendMail { $substs{"summary"} = $values{'short_desc'}; my (@headerrel, @watchingrel); while (my ($rel, $bits) = each %{$relRef}) { - push @headerrel, ($rel_names{$rel}) if ($bits & BIT_DIRECT); - push @watchingrel, ($rel_names{$rel}) if ($bits & BIT_WATCHING); + push @headerrel, (REL_NAMES->{$rel}) if ($bits & BIT_DIRECT); + push @watchingrel, (REL_NAMES->{$rel}) if ($bits & BIT_WATCHING); } push @headerrel, 'None' if !scalar(@headerrel); push @watchingrel, 'None' if !scalar(@watchingrel); -- cgit v1.2.3-24-g4f1b