Commit 44de29d0 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 312157: Remove $::template and $::vars from globals.pl - Patch by Olav…

Bug 312157: Remove $::template and $::vars from globals.pl - Patch by Olav Vitters <bugzilla-mozilla@bkor.dhs.org> r=LpSolit a=justdave
parent 46aba0e7
......@@ -74,10 +74,6 @@ use Bugzilla::BugMail;
use Bugzilla::Constants;
use Bugzilla::Field;
# Note that this line doesn't actually import these variables for some reason,
# so I have to use them as $::template and $::vars in the package code.
use vars qw($template $vars);
######################################################################
# Global Variables
######################################################################
......@@ -947,6 +943,9 @@ Sends an email notification about a flag being created or fulfilled.
sub notify {
my ($flag, $template_file) = @_;
my $template = Bugzilla->template;
my $vars = {};
my $attachment_is_private = $flag->{'target'}->{'attachment'} ?
$flag->{'target'}->{'attachment'}->{'isprivate'} : undef;
......@@ -971,14 +970,14 @@ sub notify {
$flag->{'requestee'}->{'email'} .= Param('emailsuffix');
$flag->{'setter'}->{'email'} .= Param('emailsuffix');
$::vars->{'flag'} = $flag;
$vars->{'flag'} = $flag;
my $message;
my $rv =
$::template->process($template_file, $::vars, \$message);
$template->process($template_file, $vars, \$message);
if (!$rv) {
Bugzilla->cgi->header();
ThrowTemplateError($::template->error());
ThrowTemplateError($template->error());
}
Bugzilla::BugMail::MessageToMTA($message);
......
......@@ -44,7 +44,6 @@ use MIME::Base64;
use Date::Format ();
use base qw(Template);
use vars qw($vars);
# Convert the constants in the Bugzilla::Constants module into a hash we can
# pass to the template object for reflection into its "constants" namespace
......@@ -165,6 +164,7 @@ sub getTemplateIncludePath {
sub put_header {
my $self = shift;
my $vars = {};
($vars->{'title'}, $vars->{'h1'}, $vars->{'h2'}) = (@_);
$self->process("global/header.html.tmpl", $vars)
......@@ -174,7 +174,7 @@ sub put_header {
sub put_footer {
my $self = shift;
$self->process("global/footer.html.tmpl", $vars)
$self->process("global/footer.html.tmpl")
|| ThrowTemplateError($self->error());
}
......
......@@ -60,8 +60,8 @@ sub IssueEmailChangeToken {
# Mail the user the token along with instructions for using it.
my $template = $::template;
my $vars = $::vars;
my $template = Bugzilla->template;
my $vars = {};
$vars->{'oldemailaddress'} = $old_email . Param('emailsuffix');
$vars->{'newemailaddress'} = $new_email . Param('emailsuffix');
......@@ -115,8 +115,8 @@ sub IssuePasswordToken {
# Mail the user the token along with instructions for using it.
my $template = $::template;
my $vars = $::vars;
my $template = Bugzilla->template;
my $vars = {};
$vars->{'token'} = $token;
$vars->{'emailaddress'} = $loginname . Param('emailsuffix');
......@@ -180,9 +180,10 @@ sub Cancel {
# This should only happen when the user accidentally makes a token request
# or when a malicious hacker makes a token request on behalf of a user.
my ($token, $cancelaction) = @_;
my ($token, $cancelaction, $vars) = @_;
my $dbh = Bugzilla->dbh;
$vars ||= {};
# Quote the token for inclusion in SQL statements.
my $quotedtoken = &::SqlQuote($token);
......@@ -198,8 +199,7 @@ sub Cancel {
# Get the email address of the Bugzilla maintainer.
my $maintainer = Param('maintainer');
my $template = $::template;
my $vars = $::vars;
my $template = Bugzilla->template;
$vars->{'emailaddress'} = $loginname . Param('emailsuffix');
$vars->{'maintainer'} = $maintainer;
......
......@@ -892,8 +892,6 @@ sub match_field {
# prepare default form values
my $vars = $::vars;
# What does a "--do_not_change--" field look like (if any)?
my $dontchange = $cgi->param('dontchange');
......@@ -1056,6 +1054,9 @@ sub match_field {
# Skip confirmation if we were told to, or if we don't need to confirm.
return $retval if ($behavior == MATCH_SKIP_CONFIRM || !$need_confirm);
my $template = Bugzilla->template;
my $vars = {};
$vars->{'script'} = $ENV{'SCRIPT_NAME'}; # for self-referencing URLs
$vars->{'fields'} = $fields; # fields being matched
$vars->{'matches'} = $matches; # matches that were made
......@@ -1063,8 +1064,8 @@ sub match_field {
print Bugzilla->cgi->header();
$::template->process("global/confirm-user-match.html.tmpl", $vars)
|| ThrowTemplateError($::template->error());
$template->process("global/confirm-user-match.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
......
......@@ -35,8 +35,6 @@ use strict;
use lib qw(.);
use vars qw($template $vars);
# Include the Bugzilla CGI and general utility library.
require "globals.pl";
use Bugzilla::Config qw(:locations);
......@@ -53,6 +51,8 @@ use Bugzilla::Field;
Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
################################################################################
# Main Body Execution
......
......@@ -34,8 +34,6 @@ use strict;
use lib qw(.);
use vars qw($template $vars);
use Bugzilla;
use Bugzilla::Search;
use Bugzilla::Search::Quicksearch;
......@@ -59,6 +57,8 @@ use vars qw($db_name
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
my $buffer = $cgi->query_string();
if (length($buffer) == 0) {
......
......@@ -52,10 +52,9 @@ use Bugzilla::Chart;
use Bugzilla::Series;
use Bugzilla::User;
use vars qw($vars);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
# Go back to query.cgi if we are adding a boolean chart parameter.
if (grep(/^cmd-/, $cgi->param())) {
......
......@@ -27,8 +27,6 @@ use lib qw(.);
use vars qw(
@legal_keywords
$template
$vars
);
use Bugzilla;
......@@ -41,6 +39,8 @@ Bugzilla->login();
GetVersionTable();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
# The master list not only says what fields are possible, but what order
# they get displayed in.
......
......@@ -51,7 +51,6 @@ use vars
# Use the global template variables defined in globals.pl
# to generate the output.
use vars qw($vars);
my $user = Bugzilla->login(LOGIN_OPTIONAL);
......@@ -65,6 +64,7 @@ if (Param('requirelogin') && !$user->id) {
GetVersionTable();
# Pass a bunch of Bugzilla configuration to the templates.
my $vars = {};
$vars->{'priority'} = \@::legal_priority;
$vars->{'severity'} = \@::legal_severity;
$vars->{'platform'} = \@::legal_platform;
......
......@@ -36,9 +36,6 @@ use Bugzilla::User;
use Bugzilla::BugMail;
use Bugzilla::Util;
# Shut up misguided -w warnings about "used only once":
use vars qw($template $vars);
# Just in case someone already has an account, let them get the correct footer
# on an error message. The user is logged out just after the account is
# actually created.
......@@ -46,6 +43,9 @@ Bugzilla->login(LOGIN_OPTIONAL);
my $dbh = Bugzilla->dbh;
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
print $cgi->header();
# If we're using LDAP for login, then we can't create a new account here.
......
......@@ -28,7 +28,7 @@ use Bugzilla;
use Bugzilla::Constants;
require "globals.pl";
use vars qw($vars @legal_product);
use vars qw(@legal_product);
my $user = Bugzilla->login();
......@@ -36,6 +36,7 @@ GetVersionTable();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $product = trim($cgi->param('product') || '');
my $product_id = get_product_id($product);
......
......@@ -29,13 +29,12 @@ use Bugzilla::User;
require "globals.pl";
# Use the global template variables.
use vars qw($vars $template);
Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
SendSQL("SELECT keyworddefs.name, keyworddefs.description,
COUNT(keywords.bug_id)
......
......@@ -50,8 +50,8 @@ if (defined $cgi->param('ctype') && $cgi->param('ctype') eq "xul") {
exit;
}
# Use global templatisation variables.
use vars qw($template $vars);
my $template = Bugzilla->template;
my $vars = {};
GetVersionTable();
......
......@@ -39,10 +39,10 @@ use Bugzilla::Product;
use Bugzilla::Component;
use Bugzilla::Bug;
use vars qw($template $vars);
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
#
# Preliminary checks:
......
......@@ -39,7 +39,8 @@ use Bugzilla::FlagType;
use Bugzilla::Group;
use Bugzilla::Util;
use vars qw( $template $vars );
my $template = Bugzilla->template;
my $vars = {};
# Make sure the user is logged in and is an administrator.
my $user = Bugzilla->login(LOGIN_REQUIRED);
......
......@@ -36,8 +36,8 @@ require "globals.pl";
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
use vars qw($template $vars);
my $template = Bugzilla->template;
my $vars = {};
my $user = Bugzilla->login(LOGIN_REQUIRED);
......
......@@ -31,9 +31,8 @@ use Bugzilla::Config qw(:DEFAULT $datadir);
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
use vars qw($template $vars);
my $template = Bugzilla->template;
my $vars = {};
sub Validate {
my ($name, $description) = @_;
......
......@@ -27,10 +27,10 @@ use Bugzilla::Product;
use Bugzilla::Milestone;
use Bugzilla::Bug;
use vars qw($template $vars);
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
#
# Preliminary checks:
......
......@@ -30,11 +30,12 @@ use Bugzilla::Config qw(:DEFAULT :admin :params $datadir);
use Bugzilla::Config::Common;
require "globals.pl";
use vars qw($vars @parampanels);
use vars qw(@parampanels);
my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
print $cgi->header();
......
......@@ -33,7 +33,6 @@
use strict;
use lib ".";
use vars qw ($template $vars);
use Bugzilla::Constants;
require "globals.pl";
use Bugzilla::Bug;
......@@ -55,6 +54,9 @@ my $user = Bugzilla->login(LOGIN_REQUIRED);
my $whoid = $user->id;
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
print $cgi->header();
$user->in_group('editcomponents')
......
......@@ -25,8 +25,8 @@ use Bugzilla::User::Setting;
require "globals.pl";
# Use global template variables.
use vars qw($template $vars);
my $template = Bugzilla->template;
my $vars = {};
###############################
### Subroutine Definitions ###
......
......@@ -21,8 +21,6 @@ use lib ".";
require "globals.pl";
use vars qw( $vars );
use Bugzilla;
use Bugzilla::User;
use Bugzilla::Bug;
......@@ -36,6 +34,7 @@ Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
my $userid = $user->id;
......
......@@ -38,10 +38,10 @@ use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::Product;
use Bugzilla::Version;
use vars qw($template $vars);
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
#
# Preliminary checks:
......
......@@ -30,8 +30,6 @@ use strict;
use lib ".";
require "globals.pl";
use vars qw( $vars );
use Bugzilla::Constants;
use Bugzilla::User;
use Bugzilla::Group;
......@@ -44,6 +42,7 @@ my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $dbh = Bugzilla->dbh;
my $userid = $user->id;
......
......@@ -44,8 +44,6 @@ use Bugzilla::User;
require "globals.pl";
use vars qw(
$template
$vars
@enterable_products
@legal_opsys
@legal_platform
......@@ -66,6 +64,8 @@ my $cloned_bug;
my $cloned_bug_id;
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $product = $cgi->param('product');
......
......@@ -60,9 +60,7 @@ sub globals_pl_sillyness {
$zz = @main::milestoneurl;
$zz = %main::proddesc;
$zz = @main::prodmaxvotes;
$zz = $main::template;
$zz = $main::userid;
$zz = $main::vars;
}
#
......@@ -808,8 +806,4 @@ sub OpenStates {
use Bugzilla;
$::template = Bugzilla->template();
$::vars = {};
1;
......@@ -32,8 +32,6 @@ use strict;
use lib ".";
require "globals.pl";
use vars qw($vars);
# Check whether or not the user is logged in and, if so, set the $::userid
use Bugzilla::Constants;
Bugzilla->login(LOGIN_OPTIONAL);
......@@ -55,5 +53,5 @@ my $template = Bugzilla->template;
print $cgi->header();
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("index.html.tmpl", $vars)
$template->process("index.html.tmpl")
|| ThrowTemplateError($template->error());
......@@ -36,11 +36,10 @@ use Bugzilla;
require "globals.pl";
use vars qw($template $vars);
Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $id = $cgi->param('id');
if ($id) {
......@@ -58,7 +57,7 @@ if ($id) {
print $cgi->header($format->{'ctype'});
$template->process("$format->{'template'}", $vars)
$template->process("$format->{'template'}")
|| ThrowTemplateError($template->error());
}
else {
......
......@@ -48,12 +48,12 @@ sub sillyness {
$zz = %::target_milestone;
}
# Use global template variables.
use vars qw($vars $template);
my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
# do a match on the fields if applicable
......
......@@ -80,11 +80,11 @@ my $grouplist = $user->groups_as_string;
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
my $requiremilestone = 0;
use vars qw($template $vars);
######################################################################
# Begin Data/Security Validation
######################################################################
......
......@@ -50,12 +50,12 @@ use vars qw(
@log_columns
%versions
%components
$template
$vars
);
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
my $buffer = $cgi->query_string();
if ($cgi->param("GoAheadAndLogIn")) {
......
......@@ -25,7 +25,7 @@
use strict;
use vars qw($userid $template $vars);
use vars qw($userid);
use lib qw(.);
......@@ -36,6 +36,8 @@ use Bugzilla::Constants;
Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $action = $cgi->param('action') || "";
......
......@@ -26,12 +26,14 @@ use lib ".";
require "globals.pl";
use vars qw($template $vars @legal_opsys @legal_platform @legal_severity);
use vars qw(@legal_opsys @legal_platform @legal_severity);
use Bugzilla;
use Bugzilla::Constants;
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $buffer = $cgi->query_string();
# Go straight back to query.cgi if we are adding a boolean chart.
......
......@@ -62,6 +62,7 @@ Bugzilla->switch_to_shadow_db();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
# We only want those products that the user has permissions for.
my @myproducts;
......@@ -90,6 +91,7 @@ if (! defined $cgi->param('product')) {
print $cgi->header(-Content_Disposition=>'inline; filename=bugzilla_report.html');
$template->put_header("Bug Charts");
$vars->{'header_done'} = 1;
show_chart($product);
......@@ -116,6 +118,7 @@ sub choose_product {
print $cgi->header();
$template->put_header("Bug Charts");
$vars->{'header_done'} = 1;
print <<FIN;
<center>
......@@ -185,7 +188,7 @@ sub show_chart {
my ($product) = @_;
if (! defined $cgi->param('datasets')) {
ThrowUserError("missing_datasets");
ThrowUserError("missing_datasets", $vars);
}
my $datasets = join('', $cgi->param('datasets'));
......@@ -258,7 +261,8 @@ sub generate_chart {
$product = '';
}
ThrowCodeError("chart_data_not_generated", {'product' => $product});
$vars->{'product'} = $product;
ThrowCodeError("chart_data_not_generated", $vars);
}
my @fields;
......@@ -272,15 +276,19 @@ sub generate_chart {
if (/^#/) {
if (/^# fields?: (.*)\s*$/) {
@fields = split /\||\r/, $1;
ThrowCodeError("chart_datafile_corrupt", {file => $data_file})
unless $fields[0] =~ /date/i;
unless ($fields[0] =~ /date/i) {
$vars->{'file'} = $data_file;
ThrowCodeError("chart_datafile_corrupt", $vars);
}
push @labels, grep($datasets{$_}, @fields);
}
next;
}
ThrowCodeError("chart_datafile_corrupt", {file => $data_file})
unless @fields;
unless (@fields) {
$vars->{'file'} = $data_file;
ThrowCodeError("chart_datafile_corrupt", $vars);
}
my @line = split /\|/;
my $date = $line[0];
......@@ -306,7 +314,7 @@ sub generate_chart {
close FILE;
if (! @{$data{DATE}}) {
ThrowUserError("insufficient_data_points");
ThrowUserError("insufficient_data_points", $vars);
}
my $img = Chart::Lines->new (800, 600);
......
......@@ -34,13 +34,13 @@ use Bugzilla::Flag;
use Bugzilla::FlagType;
use Bugzilla::User;
use vars qw($template $vars);
# Make sure the user is logged in.
my $user = Bugzilla->login();
my $userid = $user->id;
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
################################################################################
......
......@@ -25,13 +25,14 @@
use strict;
use lib qw(.);
use vars qw ($template $vars);
require "globals.pl";
use Bugzilla::Bug;
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
###############################################################################
# Begin Data/Security Validation
......
......@@ -30,11 +30,13 @@ use Bugzilla::User;
require "globals.pl";
use vars qw($template $vars $userid);
use vars qw($userid);
use Bugzilla::Bug;
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
if ($cgi->param('GoAheadAndLogIn')) {
Bugzilla->login(LOGIN_REQUIRED);
......
......@@ -36,12 +36,14 @@ require "globals.pl";
Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
# Connect to the shadow database if this installation is using one to improve
# performance.
Bugzilla->switch_to_shadow_db();
use vars qw($template $vars $userid);
use vars qw($userid);
my %seen;
my %edgesdone;
......
......@@ -30,12 +30,11 @@ require "globals.pl";
use Bugzilla::User;
use Bugzilla::Bug;
# Use global template variables.
use vars qw($template $vars);
Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
# Connect to the shadow database if this installation is using one to improve
# performance.
......
......@@ -20,12 +20,10 @@ use strict;
use lib ".";
require "globals.pl";
# Shut up "Used Only Once" errors
use vars qw($template $vars);
Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
###############################################################################
# Main Body Execution
......@@ -43,7 +41,7 @@ my $useragent = $ENV{HTTP_USER_AGENT};
if ($useragent =~ m:Mozilla/([1-9][0-9]*):i && $1 >= 5 && $useragent !~ m/compatible/i) {
print $cgi->header("application/vnd.mozilla.xul+xml");
# Generate and return the XUL from the appropriate template.
$template->process("sidebar.xul.tmpl", $vars)
$template->process("sidebar.xul.tmpl")
|| ThrowTemplateError($template->error());
} else {
ThrowUserError("sidebar_supports_mozilla_only");
......
......@@ -29,10 +29,10 @@ use Bugzilla::Constants; # LOGIN_*
use Bugzilla::User; # UserInGroup
require "globals.pl";
GetVersionTable();
my $template = Bugzilla->template;
my $vars = {};
# Use global template variables.
use vars qw($template $vars);
GetVersionTable();
#
# Date handling
......
......@@ -29,14 +29,14 @@ use strict;
use lib qw(.);
use vars qw($template $vars);
use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Util;
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
# Include the Bugzilla CGI and general utility library.
require "globals.pl";
......@@ -250,7 +250,7 @@ sub changeEmail {
# confirmed initially so cancel token if it is not still available
if (! is_available_username($new_email,$old_email)) {
$vars->{'email'} = $new_email; # Needed for Bugzilla::Token::Cancel's mail
Bugzilla::Token::Cancel($::token,"account_exists");
Bugzilla::Token::Cancel($::token, "account_exists", $vars);
ThrowUserError("account_exists", { email => $new_email } );
}
......@@ -324,7 +324,7 @@ sub cancelChangeEmail {
$vars->{'old_email'} = $old_email;
$vars->{'new_email'} = $new_email;
Bugzilla::Token::Cancel($::token, $vars->{'message'});
Bugzilla::Token::Cancel($::token, $vars->{'message'}, $vars);
$dbh->bz_lock_tables('tokens WRITE');
$dbh->do(q{DELETE FROM tokens WHERE userid = ?
......
......@@ -35,7 +35,10 @@ use Bugzilla::User;
require "globals.pl";
# Use global template variables.
use vars qw($template $vars $userid);
use vars qw($userid);
my $template = Bugzilla->template;
my $vars = {};
###############################################################################
# Each panel has two functions - panel Foo has a DoFoo, to get the data
......
......@@ -32,10 +32,9 @@ use Bugzilla::Bug;
require "globals.pl";
# Use global template variables
use vars qw($template $vars);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
# If the action is show_bug, you need a bug_id.
# If the action is show_user, you can supply a userid to show the votes for
......
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