Commit 2545c095 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 304601: Bugzilla::Config's :locations exports need to be in their own module…

Bug 304601: Bugzilla::Config's :locations exports need to be in their own module - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat for the main patch, r=myk for the patch about CGI.pm a=justdave Bug 328637: Remove all legal_* versioncache arrays - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=justdave Bug 110503 - Eliminate versioncache
parent b687ddef
...@@ -25,11 +25,10 @@ package Bugzilla; ...@@ -25,11 +25,10 @@ package Bugzilla;
use strict; use strict;
use Bugzilla::Constants;
use Bugzilla::Auth; use Bugzilla::Auth;
use Bugzilla::Auth::Persist::Cookie; use Bugzilla::Auth::Persist::Cookie;
use Bugzilla::CGI; use Bugzilla::CGI;
use Bugzilla::Config qw(:DEFAULT :locations);
use Bugzilla::Constants;
use Bugzilla::DB; use Bugzilla::DB;
use Bugzilla::Template; use Bugzilla::Template;
use Bugzilla::User; use Bugzilla::User;
...@@ -175,7 +174,7 @@ sub login { ...@@ -175,7 +174,7 @@ sub login {
my $authorizer = new Bugzilla::Auth(); my $authorizer = new Bugzilla::Auth();
$type = LOGIN_REQUIRED if Bugzilla->cgi->param('GoAheadAndLogIn'); $type = LOGIN_REQUIRED if Bugzilla->cgi->param('GoAheadAndLogIn');
if (!defined $type || $type == LOGIN_NORMAL) { if (!defined $type || $type == LOGIN_NORMAL) {
$type = Param('requirelogin') ? LOGIN_REQUIRED : LOGIN_NORMAL; $type = Bugzilla->params->{'requirelogin'} ? LOGIN_REQUIRED : LOGIN_NORMAL;
} }
my $authenticated_user = $authorizer->login($type); my $authenticated_user = $authorizer->login($type);
...@@ -274,7 +273,7 @@ sub switch_to_shadow_db { ...@@ -274,7 +273,7 @@ sub switch_to_shadow_db {
my $class = shift; my $class = shift;
if (!$_dbh_shadow) { if (!$_dbh_shadow) {
if (Param('shadowdb')) { if (Bugzilla->params->{'shadowdb'}) {
$_dbh_shadow = Bugzilla::DB::connect_shadow(); $_dbh_shadow = Bugzilla::DB::connect_shadow();
} else { } else {
$_dbh_shadow = $_dbh_main; $_dbh_shadow = $_dbh_main;
...@@ -329,7 +328,7 @@ sub _cleanup { ...@@ -329,7 +328,7 @@ sub _cleanup {
# When we support transactions, need to ->rollback here # When we support transactions, need to ->rollback here
$_dbh_main->disconnect if $_dbh_main; $_dbh_main->disconnect if $_dbh_main;
$_dbh_shadow->disconnect if $_dbh_shadow and Param("shadowdb"); $_dbh_shadow->disconnect if $_dbh_shadow && Bugzilla->params->{"shadowdb"};
undef $_dbh_main; undef $_dbh_main;
undef $_dbh_shadow; undef $_dbh_shadow;
undef $_dbh; undef $_dbh;
...@@ -337,6 +336,7 @@ sub _cleanup { ...@@ -337,6 +336,7 @@ sub _cleanup {
sub _load_param_values { sub _load_param_values {
my %params; my %params;
my $datadir = bz_locations()->{'datadir'};
if (-e "$datadir/params") { if (-e "$datadir/params") {
# Note that checksetup.pl sets file permissions on '$datadir/params' # Note that checksetup.pl sets file permissions on '$datadir/params'
......
...@@ -30,10 +30,6 @@ package Bugzilla::Bug; ...@@ -30,10 +30,6 @@ package Bugzilla::Bug;
use strict; use strict;
use vars qw(@legal_platform
@legal_priority @legal_severity @legal_opsys @legal_bug_status
@settable_resolution);
use CGI::Carp qw(fatalsToBrowser); use CGI::Carp qw(fatalsToBrowser);
use Bugzilla::Attachment; use Bugzilla::Attachment;
...@@ -651,8 +647,6 @@ sub choices { ...@@ -651,8 +647,6 @@ sub choices {
return $self->{'choices'} if exists $self->{'choices'}; return $self->{'choices'} if exists $self->{'choices'};
return {} if $self->{'error'}; return {} if $self->{'error'};
&::GetVersionTable();
$self->{'choices'} = {}; $self->{'choices'} = {};
$self->{prod_obj} ||= new Bugzilla::Product({name => $self->{product}}); $self->{prod_obj} ||= new Bugzilla::Product({name => $self->{product}});
...@@ -665,16 +659,16 @@ sub choices { ...@@ -665,16 +659,16 @@ sub choices {
} }
# Hack - this array contains "". See bug 106589. # Hack - this array contains "". See bug 106589.
my @res = grep ($_, @::settable_resolution); my @res = grep ($_, @{settable_resolutions()});
$self->{'choices'} = $self->{'choices'} =
{ {
'product' => \@prodlist, 'product' => \@prodlist,
'rep_platform' => \@::legal_platform, 'rep_platform' => get_legal_field_values('rep_platform'),
'priority' => \@::legal_priority, 'priority' => get_legal_field_values('priority'),
'bug_severity' => \@::legal_severity, 'bug_severity' => get_legal_field_values('bug_severity'),
'op_sys' => \@::legal_opsys, 'op_sys' => get_legal_field_values('op_sys'),
'bug_status' => \@::legal_bug_status, 'bug_status' => get_legal_field_values('bug_status'),
'resolution' => \@res, 'resolution' => \@res,
'component' => [map($_->name, @{$self->{prod_obj}->components})], 'component' => [map($_->name, @{$self->{prod_obj}->components})],
'version' => [map($_->name, @{$self->{prod_obj}->versions})], 'version' => [map($_->name, @{$self->{prod_obj}->versions})],
...@@ -684,6 +678,22 @@ sub choices { ...@@ -684,6 +678,22 @@ sub choices {
return $self->{'choices'}; return $self->{'choices'};
} }
# List of resolutions that may be set directly by hand in the bug form.
# 'MOVED' and 'DUPLICATE' are excluded from the list because setting
# bugs to those resolutions requires a special process.
sub settable_resolutions {
my $resolutions = get_legal_field_values('resolution');
my $pos = lsearch($resolutions, 'DUPLICATE');
if ($pos >= 0) {
splice(@$resolutions, $pos, 1);
}
$pos = lsearch($resolutions, 'MOVED');
if ($pos >= 0) {
splice(@$resolutions, $pos, 1);
}
return $resolutions;
}
# Convenience Function. If you need speed, use this. If you need # Convenience Function. If you need speed, use this. If you need
# other Bug fields in addition to this, just create a new Bug with # other Bug fields in addition to this, just create a new Bug with
# the alias. # the alias.
......
...@@ -102,11 +102,6 @@ END ...@@ -102,11 +102,6 @@ END
# This hash usually comes from the "mailrecipients" var in a template call. # This hash usually comes from the "mailrecipients" var in a template call.
sub Send { sub Send {
my ($id, $forced) = (@_); my ($id, $forced) = (@_);
# This only works in a sub. Probably something to do with the
# require abuse we do.
&::GetVersionTable();
return ProcessOneBug($id, $forced); return ProcessOneBug($id, $forced);
} }
......
...@@ -40,7 +40,6 @@ use CGI::Carp qw(fatalsToBrowser); ...@@ -40,7 +40,6 @@ use CGI::Carp qw(fatalsToBrowser);
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Config;
# We need to disable output buffering - see bug 179174 # We need to disable output buffering - see bug 179174
$| = 1; $| = 1;
...@@ -79,11 +78,14 @@ sub new { ...@@ -79,11 +78,14 @@ sub new {
$self->{Bugzilla_cookie_list} = []; $self->{Bugzilla_cookie_list} = [];
# Send appropriate charset # Send appropriate charset
$self->charset(Param('utf8') ? 'UTF-8' : ''); $self->charset(Bugzilla->params->{'utf8'} ? 'UTF-8' : '');
# Redirect to SSL if required # Redirect to SSL if required
if (Param('sslbase') ne '' and Param('ssl') eq 'always' and i_am_cgi()) { if (Bugzilla->params->{'sslbase'} ne ''
$self->require_https(Param('sslbase')); && Bugzilla->params->{'ssl'} eq 'always'
&& i_am_cgi())
{
$self->require_https(Bugzilla->params->{'sslbase'});
} }
# Check for errors # Check for errors
...@@ -221,8 +223,9 @@ sub send_cookie { ...@@ -221,8 +223,9 @@ sub send_cookie {
} }
# Add the default path and the domain in. # Add the default path and the domain in.
$paramhash{'-path'} = Param('cookiepath'); $paramhash{'-path'} = Bugzilla->params->{'cookiepath'};
$paramhash{'-domain'} = Param('cookiedomain') if Param('cookiedomain'); $paramhash{'-domain'} = Bugzilla->params->{'cookiedomain'}
if Bugzilla->params->{'cookiedomain'};
# Move the param list back into an array for the call to cookie(). # Move the param list back into an array for the call to cookie().
foreach (keys(%paramhash)) { foreach (keys(%paramhash)) {
......
...@@ -112,7 +112,8 @@ use vars qw(@param_list); ...@@ -112,7 +112,8 @@ use vars qw(@param_list);
do $localconfig; do $localconfig;
my %params; my %params;
# Load in the param definitions # Load in the param definitions
foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) { sub _load_params {
foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) {
$item =~ m#/([^/]+)\.pm$#; $item =~ m#/([^/]+)\.pm$#;
my $module = $1; my $module = $1;
next if ($module eq 'Common'); next if ($module eq 'Common');
...@@ -123,8 +124,8 @@ foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) { ...@@ -123,8 +124,8 @@ foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) {
} }
push(@parampanels, $module); push(@parampanels, $module);
push(@param_list, @new_param_list); push(@param_list, @new_param_list);
}
} }
# END INIT CODE # END INIT CODE
# Subroutines go here # Subroutines go here
...@@ -132,6 +133,7 @@ foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) { ...@@ -132,6 +133,7 @@ foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) {
sub Param { sub Param {
my ($param) = @_; my ($param) = @_;
_load_params unless %params;
my %param_values = %{Bugzilla->params}; my %param_values = %{Bugzilla->params};
# By this stage, the param must be in the hash # By this stage, the param must be in the hash
...@@ -153,6 +155,7 @@ sub Param { ...@@ -153,6 +155,7 @@ sub Param {
sub SetParam { sub SetParam {
my ($name, $value) = @_; my ($name, $value) = @_;
_load_params unless %params;
die "Unknown param $name" unless (exists $params{$name}); die "Unknown param $name" unless (exists $params{$name});
my $entry = $params{$name}; my $entry = $params{$name};
...@@ -176,7 +179,6 @@ sub UpdateParams { ...@@ -176,7 +179,6 @@ sub UpdateParams {
# Note that this isn't particularly 'clean' in terms of separating # Note that this isn't particularly 'clean' in terms of separating
# the backend code (ie this) from the actual params. # the backend code (ie this) from the actual params.
# We don't care about that, though # We don't care about that, though
my $param = Bugzilla->params; my $param = Bugzilla->params;
# Old Bugzilla versions stored the version number in the params file # Old Bugzilla versions stored the version number in the params file
...@@ -239,6 +241,7 @@ sub UpdateParams { ...@@ -239,6 +241,7 @@ sub UpdateParams {
# --- DEFAULTS FOR NEW PARAMS --- # --- DEFAULTS FOR NEW PARAMS ---
_load_params unless %params;
foreach my $item (@param_list) { foreach my $item (@param_list) {
my $name = $item->{'name'}; my $name = $item->{'name'};
$param->{$name} = $item->{'default'} unless exists $param->{$name}; $param->{$name} = $item->{'default'} unless exists $param->{$name};
......
...@@ -34,11 +34,18 @@ package Bugzilla::Config::BugFields; ...@@ -34,11 +34,18 @@ package Bugzilla::Config::BugFields;
use strict; use strict;
use Bugzilla::Config::Common; use Bugzilla::Config::Common;
use Bugzilla::Field;
$Bugzilla::Config::BugFields::sortkey = "04"; $Bugzilla::Config::BugFields::sortkey = "04";
sub get_param_list { sub get_param_list {
my $class = shift; my $class = shift;
my @legal_priorities = @{get_legal_field_values('priority')};
my @legal_severities = @{get_legal_field_values('bug_severity')};
my @legal_platforms = @{get_legal_field_values('rep_platform')};
my @legal_OS = @{get_legal_field_values('op_sys')};
my @param_list = ( my @param_list = (
{ {
name => 'useclassification', name => 'useclassification',
...@@ -85,23 +92,23 @@ sub get_param_list { ...@@ -85,23 +92,23 @@ sub get_param_list {
{ {
name => 'defaultpriority', name => 'defaultpriority',
type => 's', type => 's',
choices => \@::legal_priority, choices => \@legal_priorities,
default => $::legal_priority[-1], default => $legal_priorities[-1],
checker => \&check_priority checker => \&check_priority
}, },
{ {
name => 'defaultseverity', name => 'defaultseverity',
type => 's', type => 's',
choices => \@::legal_severity, choices => \@legal_severities,
default => $::legal_severity[-1], default => $legal_severities[-1],
checker => \&check_severity checker => \&check_severity
}, },
{ {
name => 'defaultplatform', name => 'defaultplatform',
type => 's', type => 's',
choices => ['', @::legal_platform], choices => ['', @legal_platforms],
default => '', default => '',
checker => \&check_platform checker => \&check_platform
}, },
...@@ -109,7 +116,7 @@ sub get_param_list { ...@@ -109,7 +116,7 @@ sub get_param_list {
{ {
name => 'defaultopsys', name => 'defaultopsys',
type => 's', type => 's',
choices => ['', @::legal_opsys], choices => ['', @legal_OS],
default => '', default => '',
checker => \&check_opsys checker => \&check_opsys
} ); } );
......
...@@ -29,34 +29,15 @@ ...@@ -29,34 +29,15 @@
# Frédéric Buclin <LpSolit@gmail.com> # Frédéric Buclin <LpSolit@gmail.com>
# #
# This file defines all the parameters that we have a GUI to edit within
# Bugzilla.
# ATTENTION!!!! THIS FILE ONLY CONTAINS THE DEFAULTS.
# You cannot change your live settings by editing this file.
# Only adding new parameters is done here. Once the parameter exists, you
# must use %baseurl%/editparams.cgi from the web to edit the settings.
# This file is included via |do|, mainly because of circular dependency issues
# (such as globals.pl -> Bugzilla::Config -> this -> Bugzilla::Config)
# which preclude compile time loading.
# Those issues may go away at some point, and the contents of this file
# moved somewhere else. Please try to avoid more dependencies from here
# to other code
# (Note that these aren't just added directly to Bugzilla::Config, because
# the backend prefs code is separate to this...)
package Bugzilla::Config::Common; package Bugzilla::Config::Common;
use strict; use strict;
use Socket; use Socket;
use Bugzilla::Config qw(:DEFAULT $templatedir $webdotdir);
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Field;
use base qw(Exporter); use base qw(Exporter);
@Bugzilla::Config::Common::EXPORT = @Bugzilla::Config::Common::EXPORT =
...@@ -132,40 +113,40 @@ sub check_sslbase { ...@@ -132,40 +113,40 @@ sub check_sslbase {
sub check_priority { sub check_priority {
my ($value) = (@_); my ($value) = (@_);
&::GetVersionTable(); my $legal_priorities = get_legal_field_values('priority');
if (lsearch(\@::legal_priority, $value) < 0) { if (lsearch($legal_priorities, $value) < 0) {
return "Must be a legal priority value: one of " . return "Must be a legal priority value: one of " .
join(", ", @::legal_priority); join(", ", @$legal_priorities);
} }
return ""; return "";
} }
sub check_severity { sub check_severity {
my ($value) = (@_); my ($value) = (@_);
&::GetVersionTable(); my $legal_severities = get_legal_field_values('bug_severity');
if (lsearch(\@::legal_severity, $value) < 0) { if (lsearch($legal_severities, $value) < 0) {
return "Must be a legal severity value: one of " . return "Must be a legal severity value: one of " .
join(", ", @::legal_severity); join(", ", @$legal_severities);
} }
return ""; return "";
} }
sub check_platform { sub check_platform {
my ($value) = (@_); my ($value) = (@_);
&::GetVersionTable(); my $legal_platforms = get_legal_field_values('rep_platform');
if (lsearch(['', @::legal_platform], $value) < 0) { if (lsearch(['', @$legal_platforms], $value) < 0) {
return "Must be empty or a legal platform value: one of " . return "Must be empty or a legal platform value: one of " .
join(", ", @::legal_platform); join(", ", @$legal_platforms);
} }
return ""; return "";
} }
sub check_opsys { sub check_opsys {
my ($value) = (@_); my ($value) = (@_);
&::GetVersionTable(); my $legal_OS = get_legal_field_values('op_sys');
if (lsearch(['', @::legal_opsys], $value) < 0) { if (lsearch(['', @$legal_OS], $value) < 0) {
return "Must be empty or a legal operating system value: one of " . return "Must be empty or a legal operating system value: one of " .
join(", ", @::legal_opsys); join(", ", @$legal_OS);
} }
return ""; return "";
} }
...@@ -177,7 +158,7 @@ sub check_shadowdb { ...@@ -177,7 +158,7 @@ sub check_shadowdb {
return ""; return "";
} }
if (!Param('shadowdbhost')) { if (!Bugzilla->params->{'shadowdbhost'}) {
return "You need to specify a host when using a shadow database"; return "You need to specify a host when using a shadow database";
} }
...@@ -215,6 +196,7 @@ sub check_webdotbase { ...@@ -215,6 +196,7 @@ sub check_webdotbase {
return "The file path \"$value\" is not a valid executable. Please specify the complete file path to 'dot' if you intend to generate graphs locally."; return "The file path \"$value\" is not a valid executable. Please specify the complete file path to 'dot' if you intend to generate graphs locally.";
} }
# Check .htaccess allows access to generated images # Check .htaccess allows access to generated images
my $webdotdir = bz_locations()->{'webdotdir'};
if(-e "$webdotdir/.htaccess") { if(-e "$webdotdir/.htaccess") {
open HTACCESS, "$webdotdir/.htaccess"; open HTACCESS, "$webdotdir/.htaccess";
if(! grep(/ \\\.png\$/,<HTACCESS>)) { if(! grep(/ \\\.png\$/,<HTACCESS>)) {
...@@ -259,8 +241,8 @@ sub check_user_verify_class { ...@@ -259,8 +241,8 @@ sub check_user_verify_class {
} elsif ($class eq 'LDAP') { } elsif ($class eq 'LDAP') {
eval "require Net::LDAP"; eval "require Net::LDAP";
return "Error requiring Net::LDAP: '$@'" if $@; return "Error requiring Net::LDAP: '$@'" if $@;
return "LDAP servername is missing" unless Param("LDAPserver"); return "LDAP servername is missing" unless Bugzilla->params->{"LDAPserver"};
return "LDAPBaseDN is empty" unless Param("LDAPBaseDN"); return "LDAPBaseDN is empty" unless Bugzilla->params->{"LDAPBaseDN"};
} else { } else {
return "Unknown user_verify_class '$class' in check_user_verify_class"; return "Unknown user_verify_class '$class' in check_user_verify_class";
} }
...@@ -282,6 +264,7 @@ sub check_languages { ...@@ -282,6 +264,7 @@ sub check_languages {
if(!scalar(@languages)) { if(!scalar(@languages)) {
return "You need to specify a language tag." return "You need to specify a language tag."
} }
my $templatedir = bz_locations()->{'templatedir'};
foreach my $language (@languages) { foreach my $language (@languages) {
if( ! -d "$templatedir/$language/custom" if( ! -d "$templatedir/$language/custom"
&& ! -d "$templatedir/$language/default") { && ! -d "$templatedir/$language/default") {
......
...@@ -35,7 +35,7 @@ use strict; ...@@ -35,7 +35,7 @@ use strict;
use File::Spec; # for find_languages use File::Spec; # for find_languages
use Bugzilla::Config qw($templatedir); use Bugzilla::Constants;
use Bugzilla::Config::Common; use Bugzilla::Config::Common;
$Bugzilla::Config::L10n::sortkey = "08"; $Bugzilla::Config::L10n::sortkey = "08";
...@@ -62,7 +62,8 @@ sub get_param_list { ...@@ -62,7 +62,8 @@ sub get_param_list {
sub find_languages { sub find_languages {
my @languages = (); my @languages = ();
opendir(DIR, $templatedir) || return "Can't open 'template' directory: $!"; opendir(DIR, bz_locations()->{'templatedir'})
|| return "Can't open 'template' directory: $!";
foreach my $dir (readdir(DIR)) { foreach my $dir (readdir(DIR)) {
next unless $dir =~ /^([a-z-]+)$/i; next unless $dir =~ /^([a-z-]+)$/i;
my $lang = $1; my $lang = $1;
......
...@@ -33,6 +33,7 @@ use strict; ...@@ -33,6 +33,7 @@ use strict;
use base qw(Exporter); use base qw(Exporter);
@Bugzilla::Constants::EXPORT = qw( @Bugzilla::Constants::EXPORT = qw(
bz_locations
CONTROLMAPNA CONTROLMAPNA
CONTROLMAPSHOWN CONTROLMAPSHOWN
CONTROLMAPDEFAULT CONTROLMAPDEFAULT
...@@ -278,8 +279,6 @@ use constant FIELD_TYPE_FREETEXT => 1; ...@@ -278,8 +279,6 @@ use constant FIELD_TYPE_FREETEXT => 1;
use constant BUG_STATE_OPEN => ('NEW', 'REOPENED', 'ASSIGNED', use constant BUG_STATE_OPEN => ('NEW', 'REOPENED', 'ASSIGNED',
'UNCONFIRMED'); 'UNCONFIRMED');
1;
# Data about what we require for different databases. # Data about what we require for different databases.
use constant DB_MODULE => { use constant DB_MODULE => {
'mysql' => {db => 'Bugzilla::DB::Mysql', db_version => '4.0.14', 'mysql' => {db => 'Bugzilla::DB::Mysql', db_version => '4.0.14',
...@@ -289,3 +288,48 @@ use constant DB_MODULE => { ...@@ -289,3 +288,48 @@ use constant DB_MODULE => {
dbd => 'DBD::Pg', dbd_version => '1.45', dbd => 'DBD::Pg', dbd_version => '1.45',
name => 'PostgreSQL'}, name => 'PostgreSQL'},
}; };
# Under mod_perl, get this from a .htaccess config variable,
# and/or default from the current 'real' dir.
# At some stage after this, it may be possible for these dir locations
# to go into localconfig. localconfig can't be specified in a config file,
# except possibly with mod_perl. If you move localconfig, you need to change
# the define here.
# $libpath is really only for mod_perl; its not yet possible to move the
# .pms elsewhere.
# $webdotdir must be in the webtree somewhere. Even if you use a local dot,
# we output images to there. Also, if $webdot dir is not relative to the
# bugzilla root directory, you'll need to change showdependencygraph.cgi to
# set image_url to the correct location.
# The script should really generate these graphs directly...
# Note that if $libpath is changed, some stuff will break, notably dependency
# graphs (since the path will be wrong in the HTML). This will be fixed at
# some point.
sub bz_locations {
my $libpath = '.';
my $project;
my $localconfig;
my $datadir;
if ($ENV{'PROJECT'} && $ENV{'PROJECT'} =~ /^(\w+)$/) {
$project = $1;
$localconfig = "$libpath/localconfig.$project";
$datadir = "$libpath/data/$project";
} else {
$localconfig = "$libpath/localconfig";
$datadir = "$libpath/data";
}
# Returns a hash of paths.
return {
'libpath' => $libpath,
'templatedir' => "$libpath/template",
'project' => $project,
'localconfig' => $localconfig,
'datadir' => $datadir,
'attachdir' => "$datadir/attachments",
'webdotdir' => "$datadir/webdot",
'extensionsdir' => "$libpath/extensions"
};
}
1;
...@@ -26,7 +26,6 @@ use base qw(Exporter); ...@@ -26,7 +26,6 @@ use base qw(Exporter);
@Bugzilla::Error::EXPORT = qw(ThrowCodeError ThrowTemplateError ThrowUserError); @Bugzilla::Error::EXPORT = qw(ThrowCodeError ThrowTemplateError ThrowUserError);
use Bugzilla::Config qw($datadir);
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Util; use Bugzilla::Util;
use Date::Format; use Date::Format;
...@@ -42,6 +41,7 @@ sub _throw_error { ...@@ -42,6 +41,7 @@ sub _throw_error {
# and the transaction is rolled back (if supported) # and the transaction is rolled back (if supported)
Bugzilla->dbh->bz_unlock_tables(UNLOCK_ABORT); Bugzilla->dbh->bz_unlock_tables(UNLOCK_ABORT);
my $datadir = bz_locations()->{'datadir'};
# If a writable $datadir/errorlog exists, log error details there. # If a writable $datadir/errorlog exists, log error details there.
if (-w "$datadir/errorlog") { if (-w "$datadir/errorlog") {
require Data::Dumper; require Data::Dumper;
...@@ -115,9 +115,9 @@ sub ThrowTemplateError { ...@@ -115,9 +115,9 @@ sub ThrowTemplateError {
# Try a template first; but if this one fails too, fall back # Try a template first; but if this one fails too, fall back
# on plain old print statements. # on plain old print statements.
if (!$template->process("global/code-error.html.tmpl", $vars)) { if (!$template->process("global/code-error.html.tmpl", $vars)) {
my $maintainer = Bugzilla::Config::Param('maintainer'); my $maintainer = Bugzilla->params->{'maintainer'};
my $error = Bugzilla::Util::html_quote($vars->{'template_error_msg'}); my $error = html_quote($vars->{'template_error_msg'});
my $error2 = Bugzilla::Util::html_quote($template->error()); my $error2 = html_quote($template->error());
print <<END; print <<END;
<tt> <tt>
<p> <p>
......
...@@ -70,7 +70,7 @@ package Bugzilla::Field; ...@@ -70,7 +70,7 @@ package Bugzilla::Field;
use strict; use strict;
use base qw(Exporter); use base qw(Exporter);
@Bugzilla::Field::EXPORT = qw(check_field get_field_id); @Bugzilla::Field::EXPORT = qw(check_field get_field_id get_legal_field_values);
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Constants; use Bugzilla::Constants;
...@@ -280,6 +280,36 @@ sub match { ...@@ -280,6 +280,36 @@ sub match {
=pod =pod
=over
=item C<get_legal_field_values($field)>
Description: returns all the legal values for a field that has a
list of legal values, like rep_platform or resolution.
The table where these values are stored must at least have
the following columns: value, isactive, sortkey.
Params: C<$field> - Name of the table where valid values are.
Returns: a reference to a list of valid values.
=back
=cut
sub get_legal_field_values {
my ($field) = @_;
my $dbh = Bugzilla->dbh;
my $result_ref = $dbh->selectcol_arrayref(
"SELECT value FROM $field
WHERE isactive = ?
ORDER BY sortkey, value", undef, (1));
return $result_ref;
}
=pod
=head2 Data Validation =head2 Data Validation
=over =over
...@@ -288,15 +318,17 @@ sub match { ...@@ -288,15 +318,17 @@ sub match {
Description: Makes sure the field $name is defined and its $value Description: Makes sure the field $name is defined and its $value
is non empty. If @legal_values is defined, this routine is non empty. If @legal_values is defined, this routine
also checks whether its value is one of the legal values checks whether its value is one of the legal values
associated with this field. If the test is successful, associated with this field, else it checks against
the default valid values for this field obtained by
C<get_legal_field_values($name)>. If the test is successful,
the function returns 1. If the test fails, an error the function returns 1. If the test fails, an error
is thrown (by default), unless $no_warn is true, in which is thrown (by default), unless $no_warn is true, in which
case the function returns 0. case the function returns 0.
Params: $name - the field name Params: $name - the field name
$value - the field value $value - the field value
@legal_values - (optional) ref to a list of legal values @legal_values - (optional) list of legal values
$no_warn - (optional) do not throw an error if true $no_warn - (optional) do not throw an error if true
Returns: 1 on success; 0 on failure if $no_warn is true (else an Returns: 1 on success; 0 on failure if $no_warn is true (else an
...@@ -310,17 +342,21 @@ sub check_field { ...@@ -310,17 +342,21 @@ sub check_field {
my ($name, $value, $legalsRef, $no_warn) = @_; my ($name, $value, $legalsRef, $no_warn) = @_;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
# If $legalsRef is undefined, we use the default valid values.
unless (defined $legalsRef) {
$legalsRef = get_legal_field_values($name);
}
if (!defined($value) if (!defined($value)
|| trim($value) eq "" || trim($value) eq ""
|| (defined($legalsRef) && lsearch($legalsRef, $value) < 0)) || lsearch($legalsRef, $value) < 0)
{ {
return 0 if $no_warn; # We don't want an error to be thrown; return. return 0 if $no_warn; # We don't want an error to be thrown; return.
trick_taint($name); trick_taint($name);
my ($result) = $dbh->selectrow_array('SELECT description FROM fielddefs
WHERE name = ?', undef, $name);
my $field = $result || $name; my $field = new Bugzilla::Field($name);
ThrowCodeError('illegal_field', { field => $field }); my $field_desc = $field ? $field->description : $name;
ThrowCodeError('illegal_field', { field => $field_desc });
} }
return 1; return 1;
} }
......
...@@ -115,8 +115,6 @@ sub init { ...@@ -115,8 +115,6 @@ sub init {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
&::GetVersionTable();
# First, deal with all the old hard-coded non-chart-based poop. # First, deal with all the old hard-coded non-chart-based poop.
if (grep(/map_assigned_to/, @$fieldsref)) { if (grep(/map_assigned_to/, @$fieldsref)) {
push @supptables, "INNER JOIN profiles AS map_assigned_to " . push @supptables, "INNER JOIN profiles AS map_assigned_to " .
...@@ -182,25 +180,26 @@ sub init { ...@@ -182,25 +180,26 @@ sub init {
# into their equivalent lists of open and closed statuses. # into their equivalent lists of open and closed statuses.
if ($params->param('bug_status')) { if ($params->param('bug_status')) {
my @bug_statuses = $params->param('bug_status'); my @bug_statuses = $params->param('bug_status');
if (scalar(@bug_statuses) == scalar(@::legal_bug_status) my @legal_statuses = @{get_legal_field_values('bug_status')};
if (scalar(@bug_statuses) == scalar(@legal_statuses)
|| $bug_statuses[0] eq "__all__") || $bug_statuses[0] eq "__all__")
{ {
$params->delete('bug_status'); $params->delete('bug_status');
} }
elsif ($bug_statuses[0] eq '__open__') { elsif ($bug_statuses[0] eq '__open__') {
$params->param('bug_status', map(is_open_state($_) ? $_ : undef, $params->param('bug_status', map(is_open_state($_) ? $_ : undef,
@::legal_bug_status)); @legal_statuses));
} }
elsif ($bug_statuses[0] eq "__closed__") { elsif ($bug_statuses[0] eq "__closed__") {
$params->param('bug_status', map(is_open_state($_) ? undef : $_, $params->param('bug_status', map(is_open_state($_) ? undef : $_,
@::legal_bug_status)); @legal_statuses));
} }
} }
if ($params->param('resolution')) { if ($params->param('resolution')) {
my @resolutions = $params->param('resolution'); my @resolutions = $params->param('resolution');
my $legal_resolutions = get_legal_field_values('resolution');
if (scalar(@resolutions) == scalar(@::legal_resolution)) { if (scalar(@resolutions) == scalar(@$legal_resolutions)) {
$params->delete('resolution'); $params->delete('resolution');
} }
} }
...@@ -924,7 +923,6 @@ sub init { ...@@ -924,7 +923,6 @@ sub init {
}, },
"^keywords,(?!changed)" => sub { "^keywords,(?!changed)" => sub {
&::GetVersionTable();
my @list; my @list;
my $table = "keywords_$chartid"; my $table = "keywords_$chartid";
foreach my $value (split(/[\s,]+/, $v)) { foreach my $value (split(/[\s,]+/, $v)) {
......
...@@ -28,6 +28,7 @@ use Bugzilla::Error; ...@@ -28,6 +28,7 @@ use Bugzilla::Error;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Keyword; use Bugzilla::Keyword;
use Bugzilla::Bug; use Bugzilla::Bug;
use Bugzilla::Field;
use base qw(Exporter); use base qw(Exporter);
@Bugzilla::Search::Quicksearch::EXPORT = qw(quicksearch); @Bugzilla::Search::Quicksearch::EXPORT = qw(quicksearch);
...@@ -144,8 +145,8 @@ sub quicksearch { ...@@ -144,8 +145,8 @@ sub quicksearch {
} }
# It's no alias either, so it's a more complex query. # It's no alias either, so it's a more complex query.
my $legal_statuses = get_legal_field_values('bug_status');
&::GetVersionTable(); my $legal_resolutions = get_legal_field_values('resolution');
# Globally translate " AND ", " OR ", " NOT " to space, pipe, dash. # Globally translate " AND ", " OR ", " NOT " to space, pipe, dash.
$searchstring =~ s/\s+AND\s+/ /g; $searchstring =~ s/\s+AND\s+/ /g;
...@@ -158,12 +159,12 @@ sub quicksearch { ...@@ -158,12 +159,12 @@ sub quicksearch {
my @closedStates; my @closedStates;
my (%states, %resolutions); my (%states, %resolutions);
foreach (@::legal_bug_status) { foreach (@$legal_statuses) {
push(@closedStates, $_) unless is_open_state($_); push(@closedStates, $_) unless is_open_state($_);
} }
foreach (@openStates) { $states{$_} = 1 } foreach (@openStates) { $states{$_} = 1 }
if ($words[0] eq 'ALL') { if ($words[0] eq 'ALL') {
foreach (@::legal_bug_status) { $states{$_} = 1 } foreach (@$legal_statuses) { $states{$_} = 1 }
shift @words; shift @words;
} }
elsif ($words[0] eq 'OPEN') { elsif ($words[0] eq 'OPEN') {
...@@ -175,7 +176,7 @@ sub quicksearch { ...@@ -175,7 +176,7 @@ sub quicksearch {
\%resolutions, \%resolutions,
[split(/,/, substr($words[0], 1))], [split(/,/, substr($words[0], 1))],
\@closedStates, \@closedStates,
\@::legal_resolution)) { $legal_resolutions)) {
shift @words; shift @words;
# Allowing additional resolutions means we need to keep # Allowing additional resolutions means we need to keep
# the "no resolution" resolution. # the "no resolution" resolution.
...@@ -191,8 +192,8 @@ sub quicksearch { ...@@ -191,8 +192,8 @@ sub quicksearch {
if (matchPrefixes(\%states, if (matchPrefixes(\%states,
\%resolutions, \%resolutions,
[split(/,/, $words[0])], [split(/,/, $words[0])],
\@::legal_bug_status, $legal_statuses,
\@::legal_resolution)) { $legal_resolutions)) {
shift @words; shift @words;
} }
else { else {
...@@ -292,7 +293,7 @@ sub quicksearch { ...@@ -292,7 +293,7 @@ sub quicksearch {
} }
# Severity # Severity
elsif (grep({lc($word) eq substr($_, 0, 3)} elsif (grep({lc($word) eq substr($_, 0, 3)}
@::legal_severity)) { @{get_legal_field_values('bug_severity')})) {
addChart('bug_severity', 'substring', addChart('bug_severity', 'substring',
$word, $negate); $word, $negate);
} }
......
...@@ -42,15 +42,11 @@ use Bugzilla::User; ...@@ -42,15 +42,11 @@ use Bugzilla::User;
use Bugzilla::Bug; use Bugzilla::Bug;
use Bugzilla::Product; use Bugzilla::Product;
use Bugzilla::Keyword; use Bugzilla::Keyword;
use Bugzilla::Field;
# Include the Bugzilla CGI and general utility library. # Include the Bugzilla CGI and general utility library.
require "globals.pl"; require "globals.pl";
use vars qw(@legal_platform
@legal_priority
@legal_severity
@settable_resolution);
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template; my $template = Bugzilla->template;
...@@ -90,7 +86,6 @@ if ($dotweak) { ...@@ -90,7 +86,6 @@ if ($dotweak) {
|| ThrowUserError("auth_failure", {group => "editbugs", || ThrowUserError("auth_failure", {group => "editbugs",
action => "modify", action => "modify",
object => "multiple_bugs"}); object => "multiple_bugs"});
GetVersionTable();
} }
# Hack to support legacy applications that think the RDF ctype is at format=rdf. # Hack to support legacy applications that think the RDF ctype is at format=rdf.
...@@ -1042,11 +1037,11 @@ if ($dotweak) { ...@@ -1042,11 +1037,11 @@ if ($dotweak) {
$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); $vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count();
$vars->{'products'} = Bugzilla->user->get_enterable_products; $vars->{'products'} = Bugzilla->user->get_enterable_products;
$vars->{'platforms'} = \@::legal_platform; $vars->{'platforms'} = get_legal_field_values('rep_platform');
$vars->{'op_sys'} = \@::legal_opsys; $vars->{'op_sys'} = get_legal_field_values('op_sys');
$vars->{'priorities'} = \@::legal_priority; $vars->{'priorities'} = get_legal_field_values('priority');
$vars->{'severities'} = \@::legal_severity; $vars->{'severities'} = get_legal_field_values('bug_severity');
$vars->{'resolutions'} = \@::settable_resolution; $vars->{'resolutions'} = Bugzilla::Bug->settable_resolutions;
$vars->{'unconfirmedstate'} = 'UNCONFIRMED'; $vars->{'unconfirmedstate'} = 'UNCONFIRMED';
......
...@@ -33,8 +33,6 @@ require "globals.pl"; ...@@ -33,8 +33,6 @@ require "globals.pl";
Bugzilla->login(); Bugzilla->login();
GetVersionTable();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
......
...@@ -52,8 +52,6 @@ if (chdir("graphs")) { ...@@ -52,8 +52,6 @@ if (chdir("graphs")) {
chdir(".."); chdir("..");
} }
GetVersionTable();
# Let Throw*Error() work correctly outside a web browser. # Let Throw*Error() work correctly outside a web browser.
Bugzilla->batch(1); Bugzilla->batch(1);
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
......
...@@ -35,19 +35,7 @@ use Bugzilla; ...@@ -35,19 +35,7 @@ use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Keyword; use Bugzilla::Keyword;
use Bugzilla::Bug; use Bugzilla::Bug;
use Bugzilla::Field;
# Suppress "used only once" warnings.
use vars
qw(
@legal_priority
@legal_severity
@legal_platform
@legal_opsys
@legal_resolution
);
# Use the global template variables defined in globals.pl
# to generate the output.
my $user = Bugzilla->login(LOGIN_OPTIONAL); my $user = Bugzilla->login(LOGIN_OPTIONAL);
...@@ -57,18 +45,15 @@ if (Param('requirelogin') && !$user->id) { ...@@ -57,18 +45,15 @@ if (Param('requirelogin') && !$user->id) {
display_data(); display_data();
} }
# Retrieve this installation's configuration.
GetVersionTable();
# Pass a bunch of Bugzilla configuration to the templates. # Pass a bunch of Bugzilla configuration to the templates.
my $vars = {}; my $vars = {};
$vars->{'priority'} = \@::legal_priority; $vars->{'priority'} = get_legal_field_values('priority');
$vars->{'severity'} = \@::legal_severity; $vars->{'severity'} = get_legal_field_values('bug_severity');
$vars->{'platform'} = \@::legal_platform; $vars->{'platform'} = get_legal_field_values('rep_platform');
$vars->{'op_sys'} = \@::legal_opsys; $vars->{'op_sys'} = get_legal_field_values('op_sys');
$vars->{'keyword'} = [map($_->name, Bugzilla::Keyword->get_all)]; $vars->{'keyword'} = [map($_->name, Bugzilla::Keyword->get_all)];
$vars->{'resolution'} = \@::legal_resolution; $vars->{'resolution'} = get_legal_field_values('resolution');
$vars->{'status'} = \@::legal_bug_status; $vars->{'status'} = get_legal_field_values('bug_status');
# Include a list of product objects. # Include a list of product objects.
$vars->{'products'} = $user->get_selectable_products; $vars->{'products'} = $user->get_selectable_products;
...@@ -77,7 +62,7 @@ $vars->{'products'} = $user->get_selectable_products; ...@@ -77,7 +62,7 @@ $vars->{'products'} = $user->get_selectable_products;
# be made part of the configuration. # be made part of the configuration.
my @open_status; my @open_status;
my @closed_status; my @closed_status;
foreach my $status (@::legal_bug_status) { foreach my $status (@{$vars->{'status'}}) {
is_open_state($status) ? push(@open_status, $status) is_open_state($status) ? push(@open_status, $status)
: push(@closed_status, $status); : push(@closed_status, $status);
} }
......
...@@ -754,32 +754,6 @@ ...@@ -754,32 +754,6 @@
</para> </para>
</section> </section>
<section id="dbmodify">
<title>Modifying Your Running System</title>
<para>
Bugzilla optimizes database lookups by storing all relatively
static information in the <filename>versioncache</filename>
file, located in the <filename class="directory">data/</filename>
subdirectory under your installation directory.
</para>
<para>
If you make a change to the structural data in your database (the
versions table for example), or to the <quote>constants</quote>
encoded in <filename>defparams.pl</filename>, you will need to remove
the cached content from the data directory (by doing a
<command>rm data/versioncache</command>), or your changes won't show up.
</para>
<para>
<filename>versioncache</filename> gets regenerated automatically
whenever it's more than an hour old, so Bugzilla will eventually
notice your changes by itself, but generally you want it to notice
right away, so that you can test things.
</para>
</section>
<section id="dbdoc"> <section id="dbdoc">
<title>MySQL Bugzilla Database Introduction</title> <title>MySQL Bugzilla Database Introduction</title>
......
...@@ -54,8 +54,6 @@ if (defined $cgi->param('ctype') && $cgi->param('ctype') eq "xul") { ...@@ -54,8 +54,6 @@ if (defined $cgi->param('ctype') && $cgi->param('ctype') eq "xul") {
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
GetVersionTable();
# collectstats.pl uses duplicates.cgi to generate the RDF duplicates stats. # collectstats.pl uses duplicates.cgi to generate the RDF duplicates stats.
# However, this conflicts with requirelogin if it's enabled; so we make # However, this conflicts with requirelogin if it's enabled; so we make
# logging-in optional if we are running from the command line. # logging-in optional if we are running from the command line.
......
...@@ -115,9 +115,6 @@ if ($action eq 'new') { ...@@ -115,9 +115,6 @@ if ($action eq 'new') {
$dbh->do("INSERT INTO classifications (name, description) $dbh->do("INSERT INTO classifications (name, description)
VALUES (?, ?)", undef, ($class_name, $description)); VALUES (?, ?)", undef, ($class_name, $description));
# Make versioncache flush
unlink "$datadir/versioncache";
$vars->{'classification'} = $class_name; $vars->{'classification'} = $class_name;
LoadTemplate($action); LoadTemplate($action);
...@@ -173,8 +170,6 @@ if ($action eq 'delete') { ...@@ -173,8 +170,6 @@ if ($action eq 'delete') {
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
unlink "$datadir/versioncache";
$vars->{'classification'} = $classification; $vars->{'classification'} = $classification;
LoadTemplate($action); LoadTemplate($action);
...@@ -224,8 +219,6 @@ if ($action eq 'update') { ...@@ -224,8 +219,6 @@ if ($action eq 'update') {
undef, ($class_name, $class_old->id)); undef, ($class_name, $class_old->id));
$vars->{'updated_classification'} = 1; $vars->{'updated_classification'} = 1;
unlink "$datadir/versioncache";
} }
if ($description ne $class_old->description) { if ($description ne $class_old->description) {
...@@ -235,8 +228,6 @@ if ($action eq 'update') { ...@@ -235,8 +228,6 @@ if ($action eq 'update') {
($description, $class_old->id)); ($description, $class_old->id));
$vars->{'updated_description'} = 1; $vars->{'updated_description'} = 1;
unlink "$datadir/versioncache";
} }
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
......
...@@ -175,8 +175,6 @@ if ($action eq 'new') { ...@@ -175,8 +175,6 @@ if ($action eq 'new') {
# Insert default charting queries for this product. # Insert default charting queries for this product.
# If they aren't using charting, this won't do any harm. # If they aren't using charting, this won't do any harm.
GetVersionTable();
my @series; my @series;
my $prodcomp = "&product=" . url_quote($product->name) . my $prodcomp = "&product=" . url_quote($product->name) .
...@@ -208,9 +206,6 @@ if ($action eq 'new') { ...@@ -208,9 +206,6 @@ if ($action eq 'new') {
$series->writeToDatabase(); $series->writeToDatabase();
} }
# Make versioncache flush
unlink "$datadir/versioncache";
$component = $component =
new Bugzilla::Component({product_id => $product->id, new Bugzilla::Component({product_id => $product->id,
name => $comp_name}); name => $comp_name});
...@@ -280,8 +275,6 @@ if ($action eq 'delete') { ...@@ -280,8 +275,6 @@ if ($action eq 'delete') {
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
unlink "$datadir/versioncache";
$vars->{'comp'} = $component; $vars->{'comp'} = $component;
$vars->{'product'} = $product; $vars->{'product'} = $product;
$template->process("admin/components/deleted.html.tmpl", $vars) $template->process("admin/components/deleted.html.tmpl", $vars)
...@@ -367,7 +360,6 @@ if ($action eq 'update') { ...@@ -367,7 +360,6 @@ if ($action eq 'update') {
$dbh->do("UPDATE components SET name = ? WHERE id = ?", $dbh->do("UPDATE components SET name = ? WHERE id = ?",
undef, ($comp_name, $component_old->id)); undef, ($comp_name, $component_old->id));
unlink "$datadir/versioncache";
$vars->{'updated_name'} = 1; $vars->{'updated_name'} = 1;
} }
......
...@@ -152,9 +152,6 @@ if ($action eq 'new') { ...@@ -152,9 +152,6 @@ if ($action eq 'new') {
(id, name, description) VALUES (?, ?, ?)', (id, name, description) VALUES (?, ?, ?)',
undef, ($newid, $name, $description)); undef, ($newid, $name, $description));
# Make versioncache flush
unlink "$datadir/versioncache";
print $cgi->header(); print $cgi->header();
$vars->{'name'} = $name; $vars->{'name'} = $name;
...@@ -226,9 +223,6 @@ if ($action eq 'update') { ...@@ -226,9 +223,6 @@ if ($action eq 'update') {
$dbh->do('UPDATE keyworddefs SET name = ?, description = ? $dbh->do('UPDATE keyworddefs SET name = ?, description = ?
WHERE id = ?', undef, ($name, $description, $id)); WHERE id = ?', undef, ($name, $description, $id));
# Make versioncache flush
unlink "$datadir/versioncache";
print $cgi->header(); print $cgi->header();
$vars->{'name'} = $name; $vars->{'name'} = $name;
...@@ -267,9 +261,6 @@ if ($action eq 'delete') { ...@@ -267,9 +261,6 @@ if ($action eq 'delete') {
$dbh->do('DELETE FROM keywords WHERE keywordid = ?', undef, $id); $dbh->do('DELETE FROM keywords WHERE keywordid = ?', undef, $id);
$dbh->do('DELETE FROM keyworddefs WHERE id = ?', undef, $id); $dbh->do('DELETE FROM keyworddefs WHERE id = ?', undef, $id);
# Make versioncache flush
unlink "$datadir/versioncache";
print $cgi->header(); print $cgi->header();
$vars->{'name'} = $name; $vars->{'name'} = $name;
......
...@@ -144,9 +144,6 @@ if ($action eq 'new') { ...@@ -144,9 +144,6 @@ if ($action eq 'new') {
VALUES ( ?, ?, ? )', VALUES ( ?, ?, ? )',
undef, $milestone_name, $product->id, $sortkey); undef, $milestone_name, $product->id, $sortkey);
# Make versioncache flush
unlink "$datadir/versioncache";
$milestone = new Bugzilla::Milestone($product->id, $milestone = new Bugzilla::Milestone($product->id,
$milestone_name); $milestone_name);
$vars->{'milestone'} = $milestone; $vars->{'milestone'} = $milestone;
...@@ -227,8 +224,6 @@ if ($action eq 'delete') { ...@@ -227,8 +224,6 @@ if ($action eq 'delete') {
$dbh->do("DELETE FROM milestones WHERE product_id = ? AND value = ?", $dbh->do("DELETE FROM milestones WHERE product_id = ? AND value = ?",
undef, ($product->id, $milestone->name)); undef, ($product->id, $milestone->name));
unlink "$datadir/versioncache";
$template->process("admin/milestones/deleted.html.tmpl", $vars) $template->process("admin/milestones/deleted.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
...@@ -292,7 +287,6 @@ if ($action eq 'update') { ...@@ -292,7 +287,6 @@ if ($action eq 'update') {
$product->id, $product->id,
$milestone_old->name); $milestone_old->name);
unlink "$datadir/versioncache";
$vars->{'updated_sortkey'} = 1; $vars->{'updated_sortkey'} = 1;
} }
...@@ -337,8 +331,6 @@ if ($action eq 'update') { ...@@ -337,8 +331,6 @@ if ($action eq 'update') {
$product->id, $product->id,
$milestone_old->name); $milestone_old->name);
unlink "$datadir/versioncache";
$vars->{'updated_name'} = 1; $vars->{'updated_name'} = 1;
} }
......
...@@ -49,14 +49,12 @@ my $current_panel = $cgi->param('section') || 'core'; ...@@ -49,14 +49,12 @@ my $current_panel = $cgi->param('section') || 'core';
$current_panel =~ /^([A-Za-z0-9_-]+)$/; $current_panel =~ /^([A-Za-z0-9_-]+)$/;
$current_panel = $1; $current_panel = $1;
GetVersionTable();
my $current_module; my $current_module;
my @panels = (); my @panels = ();
foreach my $panel (@parampanels) { foreach my $panel (@parampanels) {
next if ($panel eq 'Common'); next if ($panel eq 'Common');
require "Bugzilla/Config/$panel.pm"; require "Bugzilla/Config/$panel.pm";
my @module_param_list = "Bugzilla::Config::${panel}"->get_param_list(); my @module_param_list = "Bugzilla::Config::${panel}"->get_param_list(1);
my $item = { name => lc($panel), my $item = { name => lc($panel),
current => ($current_panel eq lc($panel)) ? 1 : 0, current => ($current_panel eq lc($panel)) ? 1 : 0,
param_list => \@module_param_list, param_list => \@module_param_list,
...@@ -70,7 +68,7 @@ $vars->{panels} = \@panels; ...@@ -70,7 +68,7 @@ $vars->{panels} = \@panels;
if ($action eq 'save' && $current_module) { if ($action eq 'save' && $current_module) {
my @changes = (); my @changes = ();
my @module_param_list = "Bugzilla::Config::${current_module}"->get_param_list(); my @module_param_list = "Bugzilla::Config::${current_module}"->get_param_list(1);
foreach my $i (@module_param_list) { foreach my $i (@module_param_list) {
my $name = $i->{'name'}; my $name = $i->{'name'};
...@@ -128,7 +126,6 @@ if ($action eq 'save' && $current_module) { ...@@ -128,7 +126,6 @@ if ($action eq 'save' && $current_module) {
$vars->{'param_changed'} = \@changes; $vars->{'param_changed'} = \@changes;
WriteParams(); WriteParams();
unlink "$datadir/versioncache";
} }
$template->process("admin/params/editparams.html.tmpl", $vars) $template->process("admin/params/editparams.html.tmpl", $vars)
......
...@@ -45,10 +45,7 @@ use Bugzilla::Classification; ...@@ -45,10 +45,7 @@ use Bugzilla::Classification;
use Bugzilla::Milestone; use Bugzilla::Milestone;
use Bugzilla::Group; use Bugzilla::Group;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Field;
# Shut up misguided -w warnings about "used only once". "use vars" just
# doesn't work for me.
use vars qw(@legal_bug_status @legal_resolution);
# #
# Preliminary checks: # Preliminary checks:
...@@ -273,8 +270,7 @@ if ($action eq 'new') { ...@@ -273,8 +270,7 @@ if ($action eq 'new') {
if ($cgi->param('createseries')) { if ($cgi->param('createseries')) {
# Insert default charting queries for this product. # Insert default charting queries for this product.
# If they aren't using charting, this won't do any harm. # If they aren't using charting, this won't do any harm.
GetVersionTable(); #
# $open_name and $product are sqlquoted by the series code # $open_name and $product are sqlquoted by the series code
# and never used again here, so we can trick_taint them. # and never used again here, so we can trick_taint them.
my $open_name = $cgi->param('open_name'); my $open_name = $cgi->param('open_name');
...@@ -283,12 +279,12 @@ if ($action eq 'new') { ...@@ -283,12 +279,12 @@ if ($action eq 'new') {
my @series; my @series;
# We do every status, every resolution, and an "opened" one as well. # We do every status, every resolution, and an "opened" one as well.
foreach my $bug_status (@::legal_bug_status) { foreach my $bug_status (@{get_legal_field_values('bug_status')}) {
push(@series, [$bug_status, push(@series, [$bug_status,
"bug_status=" . url_quote($bug_status)]); "bug_status=" . url_quote($bug_status)]);
} }
foreach my $resolution (@::legal_resolution) { foreach my $resolution (@{get_legal_field_values('resolution')}) {
next if !$resolution; next if !$resolution;
push(@series, [$resolution, "resolution=" .url_quote($resolution)]); push(@series, [$resolution, "resolution=" .url_quote($resolution)]);
} }
...@@ -309,9 +305,6 @@ if ($action eq 'new') { ...@@ -309,9 +305,6 @@ if ($action eq 'new') {
$series->writeToDatabase(); $series->writeToDatabase();
} }
} }
# Make versioncache flush
unlink "$datadir/versioncache";
$vars->{'product'} = $product; $vars->{'product'} = $product;
$template->process("admin/products/created.html.tmpl", $vars) $template->process("admin/products/created.html.tmpl", $vars)
...@@ -417,8 +410,6 @@ if ($action eq 'delete') { ...@@ -417,8 +410,6 @@ if ($action eq 'delete') {
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
unlink "$datadir/versioncache";
$template->process("admin/products/deleted.html.tmpl", $vars) $template->process("admin/products/deleted.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
...@@ -878,7 +869,6 @@ if ($action eq 'update') { ...@@ -878,7 +869,6 @@ if ($action eq 'update') {
} }
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
unlink "$datadir/versioncache";
my $product = new Bugzilla::Product({name => $product_name}); my $product = new Bugzilla::Product({name => $product_name});
......
...@@ -217,8 +217,6 @@ if ($action eq 'new') { ...@@ -217,8 +217,6 @@ if ($action eq 'new') {
VALUES ( ?, ? )"); VALUES ( ?, ? )");
$sth->execute($value, $sortkey); $sth->execute($value, $sortkey);
unlink "$datadir/versioncache";
$vars->{'value'} = $value; $vars->{'value'} = $value;
$vars->{'field'} = $field; $vars->{'field'} = $field;
$template->process("admin/fieldvalues/created.html.tmpl", $template->process("admin/fieldvalues/created.html.tmpl",
...@@ -287,8 +285,6 @@ if ($action eq 'delete') { ...@@ -287,8 +285,6 @@ if ($action eq 'delete') {
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
unlink "$datadir/versioncache";
$vars->{'value'} = $value; $vars->{'value'} = $value;
$vars->{'field'} = $field; $vars->{'field'} = $field;
$template->process("admin/fieldvalues/deleted.html.tmpl", $template->process("admin/fieldvalues/deleted.html.tmpl",
...@@ -354,7 +350,6 @@ if ($action eq 'update') { ...@@ -354,7 +350,6 @@ if ($action eq 'update') {
$dbh->do("UPDATE $field SET sortkey = ? WHERE value = ?", $dbh->do("UPDATE $field SET sortkey = ? WHERE value = ?",
undef, $sortkey, $valueold); undef, $sortkey, $valueold);
unlink "$datadir/versioncache";
$vars->{'updated_sortkey'} = 1; $vars->{'updated_sortkey'} = 1;
$vars->{'sortkey'} = $sortkey; $vars->{'sortkey'} = $sortkey;
} }
...@@ -377,8 +372,6 @@ if ($action eq 'update') { ...@@ -377,8 +372,6 @@ if ($action eq 'update') {
$dbh->do("UPDATE $field SET value = ? WHERE value = ?", $dbh->do("UPDATE $field SET value = ? WHERE value = ?",
undef, $value, $valueold); undef, $value, $valueold);
unlink "$datadir/versioncache";
$vars->{'updated_value'} = 1; $vars->{'updated_value'} = 1;
} }
...@@ -387,13 +380,12 @@ if ($action eq 'update') { ...@@ -387,13 +380,12 @@ if ($action eq 'update') {
# If the old value was the default value for the field, # If the old value was the default value for the field,
# update data/params accordingly. # update data/params accordingly.
# This update is done while tables are unlocked due to the # This update is done while tables are unlocked due to the
# annoying call to GetVersionTable in Bugzilla/Config/Common.pm. # annoying calls in Bugzilla/Config/Common.pm.
if ($value ne $valueold if ($value ne $valueold
&& $valueold eq Param($defaults{$field})) && $valueold eq Param($defaults{$field}))
{ {
SetParam($defaults{$field}, $value); SetParam($defaults{$field}, $value);
WriteParams(); WriteParams();
unlink "$datadir/versioncache";
$vars->{'default_value_updated'} = 1; $vars->{'default_value_updated'} = 1;
} }
......
...@@ -144,9 +144,6 @@ if ($action eq 'new') { ...@@ -144,9 +144,6 @@ if ($action eq 'new') {
$dbh->do("INSERT INTO versions (value, product_id) $dbh->do("INSERT INTO versions (value, product_id)
VALUES (?, ?)", undef, ($version_name, $product->id)); VALUES (?, ?)", undef, ($version_name, $product->id));
# Make versioncache flush
unlink "$datadir/versioncache";
$version = new Bugzilla::Version($product->id, $version_name); $version = new Bugzilla::Version($product->id, $version_name);
$vars->{'version'} = $version; $vars->{'version'} = $version;
$vars->{'product'} = $product; $vars->{'product'} = $product;
...@@ -201,8 +198,6 @@ if ($action eq 'delete') { ...@@ -201,8 +198,6 @@ if ($action eq 'delete') {
$dbh->do("DELETE FROM versions WHERE product_id = ? AND value = ?", $dbh->do("DELETE FROM versions WHERE product_id = ? AND value = ?",
undef, ($product->id, $version->name)); undef, ($product->id, $version->name));
unlink "$datadir/versioncache";
$vars->{'version'} = $version; $vars->{'version'} = $version;
$vars->{'product'} = $product; $vars->{'product'} = $product;
...@@ -279,8 +274,6 @@ if ($action eq 'update') { ...@@ -279,8 +274,6 @@ if ($action eq 'update') {
WHERE product_id = ? AND value = ?", undef, WHERE product_id = ? AND value = ?", undef,
($version_name, $product->id, $version_old->name)); ($version_name, $product->id, $version_old->name));
unlink "$datadir/versioncache";
$vars->{'updated_name'} = 1; $vars->{'updated_name'} = 1;
} }
......
...@@ -46,15 +46,9 @@ use Bugzilla::Product; ...@@ -46,15 +46,9 @@ use Bugzilla::Product;
use Bugzilla::Classification; use Bugzilla::Classification;
use Bugzilla::Keyword; use Bugzilla::Keyword;
use Bugzilla::Token; use Bugzilla::Token;
use Bugzilla::Field;
require "globals.pl"; require "globals.pl";
use vars qw(
@legal_opsys
@legal_platform
@legal_priority
@legal_severity
);
my $user = Bugzilla->login(LOGIN_REQUIRED); my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cloned_bug; my $cloned_bug;
...@@ -312,8 +306,6 @@ if ($cloned_bug_id) { ...@@ -312,8 +306,6 @@ if ($cloned_bug_id) {
$cloned_bug = new Bugzilla::Bug($cloned_bug_id, $user->id); $cloned_bug = new Bugzilla::Bug($cloned_bug_id, $user->id);
} }
GetVersionTable();
if (scalar(@{$product->components}) == 1) { if (scalar(@{$product->components}) == 1) {
# Only one component; just pick it. # Only one component; just pick it.
$cgi->param('component', $product->components->[0]->name); $cgi->param('component', $product->components->[0]->name);
...@@ -323,10 +315,10 @@ my %default; ...@@ -323,10 +315,10 @@ my %default;
$vars->{'product'} = $product; $vars->{'product'} = $product;
$vars->{'priority'} = \@legal_priority; $vars->{'priority'} = get_legal_field_values('priority');
$vars->{'bug_severity'} = \@legal_severity; $vars->{'bug_severity'} = get_legal_field_values('bug_severity');
$vars->{'rep_platform'} = \@legal_platform; $vars->{'rep_platform'} = get_legal_field_values('rep_platform');
$vars->{'op_sys'} = \@legal_opsys; $vars->{'op_sys'} = get_legal_field_values('op_sys');
$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); $vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count();
......
...@@ -39,23 +39,6 @@ use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir); ...@@ -39,23 +39,6 @@ use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir);
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Error; use Bugzilla::Error;
# Shut up misguided -w warnings about "used only once". For some reason,
# "use vars" chokes on me when I try it here.
sub globals_pl_sillyness {
my $zz;
$zz = @main::legal_bug_status;
$zz = @main::legal_opsys;
$zz = @main::legal_platform;
$zz = @main::legal_priority;
$zz = @main::legal_severity;
}
#
# Here are the --LOCAL-- variables defined in 'localconfig' that we'll use
# here
#
# XXX - Move this to Bugzilla::Config once code which uses these has moved out # XXX - Move this to Bugzilla::Config once code which uses these has moved out
# of globals.pl # of globals.pl
do $localconfig; do $localconfig;
...@@ -68,88 +51,6 @@ use Date::Parse; # For str2time(). ...@@ -68,88 +51,6 @@ use Date::Parse; # For str2time().
# Use standard Perl libraries for cross-platform file/directory manipulation. # Use standard Perl libraries for cross-platform file/directory manipulation.
use File::Spec; use File::Spec;
# XXXX - this needs to go away
sub GenerateVersionTable {
my $dbh = Bugzilla->dbh;
@::legal_priority = get_legal_field_values("priority");
@::legal_severity = get_legal_field_values("bug_severity");
@::legal_platform = get_legal_field_values("rep_platform");
@::legal_opsys = get_legal_field_values("op_sys");
@::legal_bug_status = get_legal_field_values("bug_status");
@::legal_resolution = get_legal_field_values("resolution");
# 'settable_resolution' is the list of resolutions that may be set
# directly by hand in the bug form. Start with the list of legal
# resolutions and remove 'MOVED' and 'DUPLICATE' because setting
# bugs to those resolutions requires a special process.
#
@::settable_resolution = @::legal_resolution;
my $w = lsearch(\@::settable_resolution, "DUPLICATE");
if ($w >= 0) {
splice(@::settable_resolution, $w, 1);
}
my $z = lsearch(\@::settable_resolution, "MOVED");
if ($z >= 0) {
splice(@::settable_resolution, $z, 1);
}
require File::Temp;
my ($fh, $tmpname) = File::Temp::tempfile("versioncache.XXXXX",
DIR => "$datadir");
print $fh "#\n";
print $fh "# DO NOT EDIT!\n";
print $fh "# This file is automatically generated at least once every\n";
print $fh "# hour by the GenerateVersionTable() sub in globals.pl.\n";
print $fh "# Any changes you make will be overwritten.\n";
print $fh "#\n";
require Data::Dumper;
print $fh (Data::Dumper->Dump([\@::legal_priority, \@::legal_severity,
\@::legal_platform, \@::legal_opsys,
\@::legal_bug_status, \@::legal_resolution],
['*::legal_priority', '*::legal_severity',
'*::legal_platform', '*::legal_opsys',
'*::legal_bug_status', '*::legal_resolution']));
print $fh (Data::Dumper->Dump([\@::settable_resolution],
['*::settable_resolution']));
print $fh "1;\n";
close $fh;
rename ($tmpname, "$datadir/versioncache")
|| die "Can't rename $tmpname to versioncache";
ChmodDataFile("$datadir/versioncache", 0666);
}
$::VersionTableLoaded = 0;
sub GetVersionTable {
return if $::VersionTableLoaded;
my $file_generated = 0;
if (!-r "$datadir/versioncache") {
GenerateVersionTable();
$file_generated = 1;
}
require "$datadir/versioncache";
$::VersionTableLoaded = 1;
}
# Returns a list of all the legal values for a field that has a
# list of legal values, like rep_platform or resolution.
sub get_legal_field_values {
my ($field) = @_;
my $dbh = Bugzilla->dbh;
my $result_ref = $dbh->selectcol_arrayref(
"SELECT value FROM $field
WHERE isactive = ?
ORDER BY sortkey, value", undef, (1));
return @$result_ref;
}
############# Live code below here (that is, not subroutine defs) ############# ############# Live code below here (that is, not subroutine defs) #############
use Bugzilla; use Bugzilla;
......
...@@ -86,6 +86,7 @@ use Bugzilla::User; ...@@ -86,6 +86,7 @@ use Bugzilla::User;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Keyword; use Bugzilla::Keyword;
use Bugzilla::Field;
use MIME::Base64; use MIME::Base64;
use MIME::Parser; use MIME::Parser;
...@@ -116,7 +117,6 @@ use constant OK_LEVEL => 3; ...@@ -116,7 +117,6 @@ use constant OK_LEVEL => 3;
use constant DEBUG_LEVEL => 2; use constant DEBUG_LEVEL => 2;
use constant ERR_LEVEL => 1; use constant ERR_LEVEL => 1;
GetVersionTable();
our @logs; our @logs;
our @attachments; our @attachments;
our $bugtotal; our $bugtotal;
...@@ -128,19 +128,6 @@ my ($timestamp) = $dbh->selectrow_array("SELECT NOW()"); ...@@ -128,19 +128,6 @@ my ($timestamp) = $dbh->selectrow_array("SELECT NOW()");
# Helper sub routines # # Helper sub routines #
############################################################################### ###############################################################################
# This can go away as soon as data/versioncache is removed. Since we still
# have to use GetVersionTable() though, it stays for now.
sub sillyness {
my $zz;
$zz = @::legal_bug_status;
$zz = @::legal_opsys;
$zz = @::legal_platform;
$zz = @::legal_priority;
$zz = @::legal_severity;
$zz = @::legal_resolution;
}
sub MailMessage { sub MailMessage {
return unless ($mail); return unless ($mail);
my $subject = shift; my $subject = shift;
...@@ -180,27 +167,6 @@ sub Error { ...@@ -180,27 +167,6 @@ sub Error {
exit; exit;
} }
# This will be implemented in Bugzilla::Field as soon as bug 31506 lands
sub check_field {
my ($name, $value, $legalsRef, $no_warn) = @_;
my $dbh = Bugzilla->dbh;
if (!defined($value)
|| trim($value) eq ""
|| (defined($legalsRef) && lsearch($legalsRef, $value) < 0))
{
return 0 if $no_warn; # We don't want an error to be thrown; return.
trick_taint($name);
my ($result) = $dbh->selectrow_array("SELECT description FROM fielddefs
WHERE name = ?", undef, $name);
my $field = $result || $name;
ThrowCodeError('illegal_field', { field => $field });
}
return 1;
}
# This subroutine handles flags for process_bug. It is generic in that # This subroutine handles flags for process_bug. It is generic in that
# it can handle both attachment flags and bug flags. # it can handle both attachment flags and bug flags.
sub flag_handler { sub flag_handler {
...@@ -741,7 +707,7 @@ sub process_bug { ...@@ -741,7 +707,7 @@ sub process_bug {
# imported is valid. If it is not we use the defaults set in the parameters. # imported is valid. If it is not we use the defaults set in the parameters.
if (defined( $bug_fields{'bug_severity'} ) if (defined( $bug_fields{'bug_severity'} )
&& check_field('bug_severity', scalar $bug_fields{'bug_severity'}, && check_field('bug_severity', scalar $bug_fields{'bug_severity'},
\@::legal_severity, ERR_LEVEL) ) undef, ERR_LEVEL) )
{ {
push( @values, $bug_fields{'bug_severity'} ); push( @values, $bug_fields{'bug_severity'} );
} }
...@@ -758,7 +724,7 @@ sub process_bug { ...@@ -758,7 +724,7 @@ sub process_bug {
if (defined( $bug_fields{'priority'} ) if (defined( $bug_fields{'priority'} )
&& check_field('priority', scalar $bug_fields{'priority'}, && check_field('priority', scalar $bug_fields{'priority'},
\@::legal_priority, ERR_LEVEL ) ) undef, ERR_LEVEL ) )
{ {
push( @values, $bug_fields{'priority'} ); push( @values, $bug_fields{'priority'} );
} }
...@@ -775,7 +741,7 @@ sub process_bug { ...@@ -775,7 +741,7 @@ sub process_bug {
if (defined( $bug_fields{'rep_platform'} ) if (defined( $bug_fields{'rep_platform'} )
&& check_field('rep_platform', scalar $bug_fields{'rep_platform'}, && check_field('rep_platform', scalar $bug_fields{'rep_platform'},
\@::legal_platform, ERR_LEVEL ) ) undef, ERR_LEVEL ) )
{ {
push( @values, $bug_fields{'rep_platform'} ); push( @values, $bug_fields{'rep_platform'} );
} }
...@@ -792,7 +758,7 @@ sub process_bug { ...@@ -792,7 +758,7 @@ sub process_bug {
if (defined( $bug_fields{'op_sys'} ) if (defined( $bug_fields{'op_sys'} )
&& check_field('op_sys', scalar $bug_fields{'op_sys'}, && check_field('op_sys', scalar $bug_fields{'op_sys'},
\@::legal_opsys, ERR_LEVEL ) ) undef, ERR_LEVEL ) )
{ {
push( @values, $bug_fields{'op_sys'} ); push( @values, $bug_fields{'op_sys'} );
} }
...@@ -898,10 +864,10 @@ sub process_bug { ...@@ -898,10 +864,10 @@ sub process_bug {
my $has_status = defined($bug_fields{'bug_status'}); my $has_status = defined($bug_fields{'bug_status'});
my $valid_res = check_field('resolution', my $valid_res = check_field('resolution',
scalar $bug_fields{'resolution'}, scalar $bug_fields{'resolution'},
\@::legal_resolution, ERR_LEVEL ); undef, ERR_LEVEL );
my $valid_status = check_field('bug_status', my $valid_status = check_field('bug_status',
scalar $bug_fields{'bug_status'}, scalar $bug_fields{'bug_status'},
\@::legal_bug_status, ERR_LEVEL ); undef, ERR_LEVEL );
my $is_open = is_open_state($bug_fields{'bug_status'}); my $is_open = is_open_state($bug_fields{'bug_status'});
my $status = $bug_fields{'bug_status'} || undef; my $status = $bug_fields{'bug_status'} || undef;
my $resolution = $bug_fields{'resolution'} || undef; my $resolution = $bug_fields{'resolution'} || undef;
......
...@@ -39,16 +39,6 @@ use Bugzilla::Product; ...@@ -39,16 +39,6 @@ use Bugzilla::Product;
use Bugzilla::Keyword; use Bugzilla::Keyword;
use Bugzilla::Token; use Bugzilla::Token;
# Shut up misguided -w warnings about "used only once". For some reason,
# "use vars" chokes on me when I try it here.
sub sillyness {
my $zz;
$zz = @::legal_opsys;
$zz = @::legal_platform;
$zz = @::legal_priority;
$zz = @::legal_severity;
}
my $user = Bugzilla->login(LOGIN_REQUIRED); my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
...@@ -248,13 +238,11 @@ if (!Param('letsubmitterchoosepriority')) { ...@@ -248,13 +238,11 @@ if (!Param('letsubmitterchoosepriority')) {
$cgi->param(-name => 'priority', -value => Param('defaultpriority')); $cgi->param(-name => 'priority', -value => Param('defaultpriority'));
} }
GetVersionTable();
# Some more sanity checking # Some more sanity checking
check_field('rep_platform', scalar $cgi->param('rep_platform'), \@::legal_platform); check_field('rep_platform', scalar $cgi->param('rep_platform'));
check_field('bug_severity', scalar $cgi->param('bug_severity'), \@::legal_severity); check_field('bug_severity', scalar $cgi->param('bug_severity'));
check_field('priority', scalar $cgi->param('priority'), \@::legal_priority); check_field('priority', scalar $cgi->param('priority'));
check_field('op_sys', scalar $cgi->param('op_sys'), \@::legal_opsys); check_field('op_sys', scalar $cgi->param('op_sys'));
check_field('bug_status', scalar $cgi->param('bug_status'), ['UNCONFIRMED', 'NEW']); check_field('bug_status', scalar $cgi->param('bug_status'), ['UNCONFIRMED', 'NEW']);
check_field('version', scalar $cgi->param('version'), check_field('version', scalar $cgi->param('version'),
[map($_->name, @{$product->versions})]); [map($_->name, @{$product->versions})]);
......
...@@ -64,15 +64,6 @@ use Bugzilla::Keyword; ...@@ -64,15 +64,6 @@ use Bugzilla::Keyword;
use Bugzilla::Flag; use Bugzilla::Flag;
use Bugzilla::FlagType; use Bugzilla::FlagType;
# Shut up misguided -w warnings about "used only once":
use vars qw(%legal_opsys
%legal_platform
%legal_priority
%settable_resolution
%legal_severity
);
my $user = Bugzilla->login(LOGIN_REQUIRED); my $user = Bugzilla->login(LOGIN_REQUIRED);
my $whoid = $user->id; my $whoid = $user->id;
my $grouplist = $user->groups_as_string; my $grouplist = $user->groups_as_string;
...@@ -266,8 +257,6 @@ if ($cgi->cookie("BUGLIST") && defined $cgi->param('id')) { ...@@ -266,8 +257,6 @@ if ($cgi->cookie("BUGLIST") && defined $cgi->param('id')) {
$vars->{'bug_list'} = \@bug_list; $vars->{'bug_list'} = \@bug_list;
} }
GetVersionTable();
foreach my $field_name ('product', 'component', 'version') { foreach my $field_name ('product', 'component', 'version') {
defined($cgi->param($field_name)) defined($cgi->param($field_name))
|| ThrowCodeError('undefined_field', { field => $field_name }); || ThrowCodeError('undefined_field', { field => $field_name });
...@@ -639,10 +628,10 @@ if (defined $cgi->param('id')) { ...@@ -639,10 +628,10 @@ if (defined $cgi->param('id')) {
check_field('target_milestone', scalar $cgi->param('target_milestone'), check_field('target_milestone', scalar $cgi->param('target_milestone'),
[map($_->name, @{$prod_obj->milestones})]); [map($_->name, @{$prod_obj->milestones})]);
} }
check_field('rep_platform', scalar $cgi->param('rep_platform'), \@::legal_platform); check_field('rep_platform', scalar $cgi->param('rep_platform'));
check_field('op_sys', scalar $cgi->param('op_sys'), \@::legal_opsys); check_field('op_sys', scalar $cgi->param('op_sys'));
check_field('priority', scalar $cgi->param('priority'), \@::legal_priority); check_field('priority', scalar $cgi->param('priority'));
check_field('bug_severity', scalar $cgi->param('bug_severity'), \@::legal_severity); check_field('bug_severity', scalar $cgi->param('bug_severity'));
# Those fields only have to exist. We don't validate their value here. # Those fields only have to exist. We don't validate their value here.
foreach my $field_name ('bug_file_loc', 'short_desc', 'longdesclength') { foreach my $field_name ('bug_file_loc', 'short_desc', 'longdesclength') {
...@@ -1173,7 +1162,7 @@ SWITCH: for ($cgi->param('knob')) { ...@@ -1173,7 +1162,7 @@ SWITCH: for ($cgi->param('knob')) {
/^(resolve|change_resolution)$/ && CheckonComment( "resolve" ) && do { /^(resolve|change_resolution)$/ && CheckonComment( "resolve" ) && do {
# Check here, because its the only place we require the resolution # Check here, because its the only place we require the resolution
check_field('resolution', scalar $cgi->param('resolution'), check_field('resolution', scalar $cgi->param('resolution'),
\@::settable_resolution); Bugzilla::Bug->settable_resolutions);
# don't resolve as fixed while still unresolved blocking bugs # don't resolve as fixed while still unresolved blocking bugs
if (Param("noresolveonopenblockers") if (Param("noresolveonopenblockers")
......
...@@ -37,15 +37,7 @@ use Bugzilla::User; ...@@ -37,15 +37,7 @@ use Bugzilla::User;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Product; use Bugzilla::Product;
use Bugzilla::Keyword; use Bugzilla::Keyword;
use Bugzilla::Field;
use vars qw(
@legal_resolution
@legal_bug_status
@legal_opsys
@legal_platform
@legal_priority
@legal_severity
);
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
...@@ -240,12 +232,10 @@ if (Param('usetargetmilestone')) { ...@@ -240,12 +232,10 @@ if (Param('usetargetmilestone')) {
$vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count(); $vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count();
GetVersionTable(); my $legal_resolutions = get_legal_field_values('resolution');
push(@$legal_resolutions, "---"); # Oy, what a hack.
push @::legal_resolution, "---"; # Oy, what a hack. # Another hack - this array contains "" for some reason. See bug 106589.
shift @::legal_resolution; $vars->{'resolution'} = [grep ($_, @$legal_resolutions)];
# Another hack - this array contains "" for some reason. See bug 106589.
$vars->{'resolution'} = \@::legal_resolution;
my @chfields; my @chfields;
...@@ -272,11 +262,11 @@ if (UserInGroup(Param('timetrackinggroup'))) { ...@@ -272,11 +262,11 @@ if (UserInGroup(Param('timetrackinggroup'))) {
} }
@chfields = (sort(@chfields)); @chfields = (sort(@chfields));
$vars->{'chfield'} = \@chfields; $vars->{'chfield'} = \@chfields;
$vars->{'bug_status'} = \@::legal_bug_status; $vars->{'bug_status'} = get_legal_field_values('bug_status');
$vars->{'rep_platform'} = \@::legal_platform; $vars->{'rep_platform'} = get_legal_field_values('rep_platform');
$vars->{'op_sys'} = \@::legal_opsys; $vars->{'op_sys'} = get_legal_field_values('op_sys');
$vars->{'priority'} = \@::legal_priority; $vars->{'priority'} = get_legal_field_values('priority');
$vars->{'bug_severity'} = \@::legal_severity; $vars->{'bug_severity'} = get_legal_field_values('bug_severity');
# Boolean charts # Boolean charts
my @fields; my @fields;
......
...@@ -26,10 +26,9 @@ use lib "."; ...@@ -26,10 +26,9 @@ use lib ".";
require "globals.pl"; require "globals.pl";
use vars qw(@legal_opsys @legal_platform @legal_severity);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Field;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template; my $template = Bugzilla->template;
...@@ -48,8 +47,6 @@ if (grep(/^cmd-/, $cgi->param())) { ...@@ -48,8 +47,6 @@ if (grep(/^cmd-/, $cgi->param())) {
use Bugzilla::Search; use Bugzilla::Search;
GetVersionTable();
Bugzilla->login(); Bugzilla->login();
my $dbh = Bugzilla->switch_to_shadow_db(); my $dbh = Bugzilla->switch_to_shadow_db();
...@@ -329,12 +326,12 @@ sub get_names { ...@@ -329,12 +326,12 @@ sub get_names {
my ($names, $isnumeric, $field) = @_; my ($names, $isnumeric, $field) = @_;
# These are all the fields we want to preserve the order of in reports. # These are all the fields we want to preserve the order of in reports.
my %fields = ('priority' => \@::legal_priority, my %fields = ('priority' => get_legal_field_values('priority'),
'bug_severity' => \@::legal_severity, 'bug_severity' => get_legal_field_values('bug_severity'),
'rep_platform' => \@::legal_platform, 'rep_platform' => get_legal_field_values('rep_platform'),
'op_sys' => \@::legal_opsys, 'op_sys' => get_legal_field_values('op_sys'),
'bug_status' => \@::legal_bug_status, 'bug_status' => get_legal_field_values('bug_status'),
'resolution' => [' ', @::legal_resolution]); 'resolution' => [' ', @{get_legal_field_values('resolution')}]);
my $field_list = $fields{$field}; my $field_list = $fields{$field};
my @sorted; my @sorted;
......
...@@ -55,8 +55,6 @@ use Bugzilla; ...@@ -55,8 +55,6 @@ use Bugzilla;
# to viewing reports, as well. Time to check the login in that case. # to viewing reports, as well. Time to check the login in that case.
my $user = Bugzilla->login(); my $user = Bugzilla->login();
GetVersionTable();
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -54,8 +54,6 @@ if (!$cgi->param('id') && $single) { ...@@ -54,8 +54,6 @@ if (!$cgi->param('id') && $single) {
my $format = $template->get_format("bug/show", scalar $cgi->param('format'), my $format = $template->get_format("bug/show", scalar $cgi->param('format'),
scalar $cgi->param('ctype')); scalar $cgi->param('ctype'));
GetVersionTable();
my @bugs = (); my @bugs = ();
my %marks; my %marks;
......
...@@ -33,8 +33,6 @@ require "globals.pl"; ...@@ -33,8 +33,6 @@ require "globals.pl";
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
GetVersionTable();
# #
# Date handling # Date handling
# #
......
...@@ -433,8 +433,6 @@ Bugzilla->login(LOGIN_REQUIRED); ...@@ -433,8 +433,6 @@ Bugzilla->login(LOGIN_REQUIRED);
$cgi->param('Bugzilla_login', $bugzilla_login); $cgi->param('Bugzilla_login', $bugzilla_login);
$cgi->param('Bugzilla_password', $bugzilla_password); $cgi->param('Bugzilla_password', $bugzilla_password);
GetVersionTable();
$vars->{'changes_saved'} = $cgi->param('dosave'); $vars->{'changes_saved'} = $cgi->param('dosave');
my $current_tab_name = $cgi->param('tab') || "account"; my $current_tab_name = $cgi->param('tab') || "account";
......
...@@ -112,8 +112,6 @@ sub show_bug { ...@@ -112,8 +112,6 @@ sub show_bug {
# Display all the votes for a particular user. If it's the user # Display all the votes for a particular user. If it's the user
# doing the viewing, give them the option to edit them too. # doing the viewing, give them the option to edit them too.
sub show_user { sub show_user {
GetVersionTable();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user; my $user = Bugzilla->user;
...@@ -253,9 +251,6 @@ sub record_votes { ...@@ -253,9 +251,6 @@ sub record_votes {
############################################################################ ############################################################################
# End Data/Security Validation # End Data/Security Validation
############################################################################ ############################################################################
GetVersionTable();
my $who = Bugzilla->user->id; my $who = Bugzilla->user->id;
# If the user is voting for bugs, make sure they aren't overstuffing # If the user is voting for bugs, make sure they aren't overstuffing
......
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