Bugzilla->login();
-my $cgi = Bugzilla->cgi;
-my $template = Bugzilla->template;
-my $vars = {};
+# For most scripts we don't make $cgi and $template global variables. But
+# when preparing Bugzilla for mod_perl, this script used these
+# variables in so many subroutines that it was easier to just
+# make them globals.
+local our $cgi = Bugzilla->cgi;
+local our $template = Bugzilla->template;
+local our $vars = {};
################################################################################
# Main Body Execution
# Utilities
################################################################################
-my @weekday= qw( Sun Mon Tue Wed Thu Fri Sat );
+local our @weekday= qw( Sun Mon Tue Wed Thu Fri Sat );
sub DiffDate {
my ($datestr) = @_;
my $date = str2time($datestr);
# Note: For column names using aliasing (SQL "<field> AS <alias>"), the column
# ID needs to be identical to the field ID for list ordering to work.
-my $columns = {};
+local our $columns = {};
sub DefineColumn {
my ($id, $name, $title) = @_;
$columns->{$id} = { 'name' => $name , 'title' => $title };
use Bugzilla::Series;
use Bugzilla::User;
-my $cgi = Bugzilla->cgi;
-my $template = Bugzilla->template;
-my $vars = {};
+# For most scripts we don't make $cgi and $template global variables. But
+# when preparing Bugzilla for mod_perl, this script used these
+# variables in so many subroutines that it was easier to just
+# make them globals.
+local our $cgi = Bugzilla->cgi;
+local our $template = Bugzilla->template;
+local our $vars = {};
# Go back to query.cgi if we are adding a boolean chart parameter.
if (grep(/^cmd-/, $cgi->param())) {
# Get params from URL
sub formvalue {
my ($name, $default) = (@_);
- return $cgi->param($name) || $default || "";
+ return Bugzilla->cgi->param($name) || $default || "";
}
my $sortby = formvalue("sortby");
use Bugzilla::Error;
use Bugzilla::Classification;
-my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
+my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
-my $vars = {};
+local our $vars = {};
sub LoadTemplate {
my $action = shift;
+ my $cgi = Bugzilla->cgi;
+ my $template = Bugzilla->template;
$action =~ /(\w+)/;
$action = $1;
use List::Util qw(reduce);
-my $template = Bugzilla->template;
-my $vars = {};
+local our $cgi = Bugzilla->cgi;
+local our $template = Bugzilla->template;
+local our $vars = {};
# Make sure the user is logged in and is an administrator.
my $user = Bugzilla->login(LOGIN_REQUIRED);
action => "edit",
object => "flagtypes"});
-my $cgi = Bugzilla->cgi;
-
################################################################################
# Main Body Execution
################################################################################
}
if ($action eq 'list') { list(); }
-elsif ($action eq 'enter') { edit(); }
-elsif ($action eq 'copy') { edit(); }
-elsif ($action eq 'edit') { edit(); }
+elsif ($action eq 'enter') { edit($action); }
+elsif ($action eq 'copy') { edit($action); }
+elsif ($action eq 'edit') { edit($action); }
elsif ($action eq 'insert') { insert(); }
elsif ($action eq 'update') { update(); }
elsif ($action eq 'confirmdelete') { confirmDelete(); }
sub edit {
+ my ($action) = @_;
$action eq 'enter' ? validateTargetType() : (my $id = validateID());
my $dbh = Bugzilla->dbh;
validateGroups();
my $dbh = Bugzilla->dbh;
+ my $user = Bugzilla->user;
$dbh->bz_lock_tables('flagtypes WRITE', 'products READ',
'components READ', 'flaginclusions WRITE',
'flagexclusions WRITE');
use Bugzilla::User::Setting;
my $template = Bugzilla->template;
-my $vars = {};
+local our $vars = {};
###############################
### Subroutine Definitions ###
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
-my $vars = {};
my $dbh = Bugzilla->dbh;
my $userid = $user->id;
my $editusers = $user->in_group('editusers');
+local our $vars = {};
# Reject access if there is no sense in continuing.
$editusers
# Copy incoming list selection values from CGI params to template variables.
sub mirrorListSelectionValues {
+ my $cgi = Bugzilla->cgi;
if (defined($cgi->param('matchtype'))) {
foreach ('matchvalue', 'matchstr', 'matchtype', 'grouprestrict', 'groupid') {
$vars->{'listselectionvalues'}{$_} = $cgi->param($_);
my $otheruserid = shift;
my $otheruser = new Bugzilla::User($otheruserid);
my $query;
+ my $user = Bugzilla->user;
my $dbh = Bugzilla->dbh;
my $grouplist = $otheruser->groups_as_string;
sub edit_processing {
my $otherUser = shift;
+ my $user = Bugzilla->user;
+ my $template = Bugzilla->template;
- $editusers || $user->can_see_user($otherUser)
+ $user->in_group('editusers') || $user->can_see_user($otherUser)
|| ThrowUserError('auth_failure', {reason => "not_visible",
action => "modify",
object => "user"});
# the subject and body of each event that user owns
sub get_events {
my $userid = shift;
+ my $dbh = Bugzilla->dbh;
my $events = {};
my $sth = $dbh->prepare("SELECT DISTINCT id, subject, body " .
##############################################################################
sub formvalue {
my ($name, $default) = (@_);
- return $cgi->param($name) || $default || "";
+ return Bugzilla->cgi->param($name) || $default || "";
}
# Takes the name of a field and a list of possible values for that
use Bugzilla::FlagType;
my $user = Bugzilla->login(LOGIN_REQUIRED);
-my $whoid = $user->id;
+local our $whoid = $user->id;
my $grouplist = $user->groups_as_string;
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
-my $vars = {};
+local our $vars = {};
$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count();
my @editable_bug_fields = editable_bug_fields();
#
sub CheckonComment {
my ($function) = (@_);
+ my $cgi = Bugzilla->cgi;
# Param is 1 if comment should be added !
my $ret = Bugzilla->params->{ "commenton" . $function };
# Confirm that the reporter of the current bug can access the bug we are duping to.
sub DuplicateUserConfirm {
+ my $cgi = Bugzilla->cgi;
+ my $dbh = Bugzilla->dbh;
+ my $template = Bugzilla->template;
+
# if we've already been through here, then exit
if (defined $cgi->param('confirm_add_duplicate')) {
return;
$::query = "UPDATE bugs SET";
$::comma = "";
-my @values;
+local our @values;
umask(0);
sub _remove_remaining_time {
+ my $cgi = Bugzilla->cgi;
if (UserInGroup(Bugzilla->params->{'timetrackinggroup'})) {
if ( defined $cgi->param('remaining_time')
&& $cgi->param('remaining_time') > 0 )
# $everconfirmed is used by ChangeStatus() to determine whether we are
# confirming the bug or not.
-my $everconfirmed;
+local our $everconfirmed;
sub DoConfirm {
- if ($bug->check_can_change_field("canconfirm", 0, 1, \$PrivilegesRequired)) {
+ my $bug = shift;
+ if ($bug->check_can_change_field("canconfirm", 0, 1,
+ \$PrivilegesRequired))
+ {
DoComma();
$::query .= "everconfirmed = 1";
$everconfirmed = 1;
sub ChangeStatus {
my ($str) = (@_);
+ my $cgi = Bugzilla->cgi;
+ my $dbh = Bugzilla->dbh;
+
if (!$cgi->param('dontchange')
|| $str ne $cgi->param('dontchange')) {
DoComma();
sub ChangeResolution {
my ($str) = (@_);
+ my $dbh = Bugzilla->dbh;
+ my $cgi = Bugzilla->cgi;
+
if (!$cgi->param('dontchange')
|| $str ne $cgi->param('dontchange'))
{
last SWITCH;
};
/^confirm$/ && CheckonComment( "confirm" ) && do {
- DoConfirm();
+ DoConfirm($bug);
ChangeStatus('NEW');
last SWITCH;
};
/^accept$/ && CheckonComment( "accept" ) && do {
- DoConfirm();
+ DoConfirm($bug);
ChangeStatus('ASSIGNED');
if (Bugzilla->params->{"usetargetmilestone"}
&& Bugzilla->params->{"musthavemilestoneonaccept"})
};
/^reassign$/ && CheckonComment( "reassign" ) && do {
if ($cgi->param('andconfirm')) {
- DoConfirm();
+ DoConfirm($bug);
}
ChangeStatus('NEW');
DoComma();
};
/^reassignbycomponent$/ && CheckonComment( "reassignbycomponent" ) && do {
if ($cgi->param('compconfirm')) {
- DoConfirm();
+ DoConfirm($bug);
}
ChangeStatus('NEW');
last SWITCH;
}
my $basequery = $::query;
-my $delta_ts;
-
+local our $delta_ts;
sub SnapShotBug {
my ($id) = (@_);
+ my $dbh = Bugzilla->dbh;
my @row = $dbh->selectrow_array(q{SELECT delta_ts, } .
- join(',', @editable_bug_fields).q{ FROM bugs WHERE bug_id = ?},
+ join(',', editable_bug_fields()).q{ FROM bugs WHERE bug_id = ?},
undef, $id);
$delta_ts = shift @row;
sub SnapShotDeps {
my ($i, $target, $me) = (@_);
+ my $dbh = Bugzilla->dbh;
my $list = $dbh->selectcol_arrayref(qq{SELECT $target FROM dependencies
WHERE $me = ? ORDER BY $target},
undef, $i);
my $timestamp;
-my $bug_changed;
+local our $bug_changed;
sub LogDependencyActivity {
my ($i, $oldstr, $target, $me, $timestamp) = (@_);
+ my $dbh = Bugzilla->dbh;
my $newstr = SnapShotDeps($i, $target, $me);
if ($oldstr ne $newstr) {
# Figure out what's really different...
undef, ($userid, DEFAULT_QUERY_NAME));
}
-my %default;
+local our %default;
# We pass the defaults as a hash of references to arrays. For those
# Items which are single-valued, the template should only reference [0]
eval "use Chart::Lines";
$@ && ThrowCodeError("chart_lines_not_installed");
-my $dir = bz_locations()->{'datadir'} . "/mining";
-my $graph_dir = "graphs";
+local our $dir = bz_locations()->{'datadir'} . "/mining";
+local our $graph_dir = bz_locations()->{'libpath'} . "/graphs";
# If we're using bug groups for products, we should apply those restrictions
# to viewing reports, as well. Time to check the login in that case.
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
-my $vars = {};
+local our $vars = {};
# We only want those products that the user has permissions for.
my @myproducts;
sub choose_product {
my @myproducts = (@_);
-
+ my $cgi = Bugzilla->cgi;
+ my $template = Bugzilla->template;
+
my $datafile = daily_stats_filename('-All-');
# Can we do bug charts?
sub show_chart {
my ($product) = @_;
+ my $cgi = Bugzilla->cgi;
if (! defined $cgi->param('datasets')) {
ThrowUserError("missing_datasets", $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 = {};
+local our $vars = {};
################################################################################
sub queue {
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
+ my $template = Bugzilla->template;
+ my $user = Bugzilla->user;
+ my $userid = $user->id;
my $status = validateStatus($cgi->param('status'));
my $form_group = validateGroup($cgi->param('group'));
sub CrossCheck {
my $table = shift @_;
my $field = shift @_;
+ my $dbh = Bugzilla->dbh;
Status("Checking references to $table.$field");
my $table = shift @_;
my $field1 = shift @_;
my $field2 = shift @_;
+ my $dbh = Bugzilla->dbh;
Status("Checking references to $table.$field1 / $table.$field2");
# Perform vote/keyword cache checks
###########################################################################
-my $offervotecacherebuild = 0;
-
sub AlertBadVoteCache {
my ($id) = (@_);
Alert("Bad vote cache for bug " . BugLink($id));
- $offervotecacherebuild = 1;
}
$sth = $dbh->prepare(q{SELECT bug_id, votes, keywords
$dbh->sql_group_by('bug_id'));
$sth->execute;
+my $offer_votecache_rebuild = 0;
+
while (my ($id, $v) = $sth->fetchrow_array) {
if ($v <= 0) {
Alert("Bad vote sum for bug $id");
} else {
if (!defined $votes{$id} || $votes{$id} != $v) {
AlertBadVoteCache($id);
+ $offer_votecache_rebuild = 1;
}
delete $votes{$id};
}
}
foreach my $id (keys %votes) {
AlertBadVoteCache($id);
+ $offer_votecache_rebuild = 1;
}
-if ($offervotecacherebuild) {
+if ($offer_votecache_rebuild) {
print qq{<a href="sanitycheck.cgi?rebuildvotecache=1">Click here to rebuild the vote cache</a><p>\n};
}
sub BugCheck {
my ($middlesql, $errortext, $repairparam, $repairtext) = @_;
+ my $dbh = Bugzilla->dbh;
my $badbugs = $dbh->selectcol_arrayref(qq{SELECT DISTINCT bugs.bug_id
FROM $middlesql
sub DateCheck {
my $table = shift @_;
my $field = shift @_;
+ my $dbh = Bugzilla->dbh;
+
Status("Checking dates in $table.$field");
my $c = $dbh->selectrow_array(qq{SELECT COUNT($field)
FROM $table
# performance.
my $dbh = Bugzilla->switch_to_shadow_db();
-my %seen;
-my %edgesdone;
-my %bugtitles; # html title attributes for imagemap areas
-
+local our (%seen, %edgesdone, %bugtitles);
# CreateImagemap: This sub grabs a local filename as a parameter, reads the
# dot-generated image map datafile residing in that file and turns it into
use Bugzilla::Token;
use Bugzilla::User;
-my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
-my $template = Bugzilla->template;
-my $vars = {};
+local our $cgi = Bugzilla->cgi;
+local our $template = Bugzilla->template;
+local our $vars = {};
Bugzilla->login(LOGIN_OPTIONAL);
use Bugzilla::User;
my $template = Bugzilla->template;
-my $vars = {};
+local our $vars = {};
###############################################################################
# Each panel has two functions - panel Foo has a DoFoo, to get the data
use List::Util qw(min);
my $cgi = Bugzilla->cgi;
-my $template = Bugzilla->template;
-my $vars = {};
+local our $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
sub show_bug {
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
+ my $template = Bugzilla->template;
+ my $bug_id = $cgi->param('bug_id');
ThrowCodeError("missing_bug_id") unless defined $bug_id;
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
+ my $template = Bugzilla->template;
+ my $bug_id = $cgi->param('bug_id');
# If a bug_id is given, and we're editing, we'll add it to the votes list.
$bug_id ||= "";
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
+ my $template = Bugzilla->template;
# Build a list of bug IDs for which votes have been submitted. Votes
# are submitted in form fields in which the field names are the bug