summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2006-06-20 05:15:17 +0200
committerlpsolit%gmail.com <>2006-06-20 05:15:17 +0200
commit2545c0950c4f0fde8f78b265217fa9f523eff7bf (patch)
tree5bb305644ad11da196c7613b82743e426e2fd337
parentb687ddef9b6dfeec3d87b7ae211decbf21b6e9a9 (diff)
downloadbugzilla-2545c0950c4f0fde8f78b265217fa9f523eff7bf.tar.gz
bugzilla-2545c0950c4f0fde8f78b265217fa9f523eff7bf.tar.xz
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
-rw-r--r--Bugzilla.pm10
-rwxr-xr-xBugzilla/Bug.pm40
-rw-r--r--Bugzilla/BugMail.pm5
-rw-r--r--Bugzilla/CGI.pm15
-rw-r--r--Bugzilla/Config.pm27
-rw-r--r--Bugzilla/Config/BugFields.pm19
-rw-r--r--Bugzilla/Config/Common.pm53
-rw-r--r--Bugzilla/Config/L10n.pm5
-rw-r--r--Bugzilla/Constants.pm48
-rw-r--r--Bugzilla/Error.pm8
-rw-r--r--Bugzilla/Field.pm54
-rw-r--r--Bugzilla/Search.pm14
-rw-r--r--Bugzilla/Search/Quicksearch.pm17
-rwxr-xr-xbuglist.cgi17
-rwxr-xr-xcolchange.cgi2
-rwxr-xr-xcollectstats.pl2
-rwxr-xr-xconfig.cgi31
-rw-r--r--docs/xml/customization.xml26
-rwxr-xr-xduplicates.cgi2
-rwxr-xr-xeditclassifications.cgi11
-rwxr-xr-xeditcomponents.cgi8
-rwxr-xr-xeditkeywords.cgi9
-rwxr-xr-xeditmilestones.cgi8
-rwxr-xr-xeditparams.cgi7
-rwxr-xr-xeditproducts.cgi20
-rwxr-xr-xeditvalues.cgi10
-rwxr-xr-xeditversions.cgi7
-rwxr-xr-xenter_bug.cgi18
-rw-r--r--globals.pl99
-rwxr-xr-ximportxml.pl48
-rwxr-xr-xpost_bug.cgi22
-rwxr-xr-xprocess_bug.cgi21
-rwxr-xr-xquery.cgi30
-rwxr-xr-xreport.cgi17
-rwxr-xr-xreports.cgi2
-rwxr-xr-xshow_bug.cgi2
-rwxr-xr-xsummarize_time.cgi2
-rwxr-xr-xuserprefs.cgi2
-rwxr-xr-xvotes.cgi5
39 files changed, 260 insertions, 483 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index fc2ef8af5..ea7740151 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -25,11 +25,10 @@ package Bugzilla;
use strict;
+use Bugzilla::Constants;
use Bugzilla::Auth;
use Bugzilla::Auth::Persist::Cookie;
use Bugzilla::CGI;
-use Bugzilla::Config qw(:DEFAULT :locations);
-use Bugzilla::Constants;
use Bugzilla::DB;
use Bugzilla::Template;
use Bugzilla::User;
@@ -175,7 +174,7 @@ sub login {
my $authorizer = new Bugzilla::Auth();
$type = LOGIN_REQUIRED if Bugzilla->cgi->param('GoAheadAndLogIn');
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);
@@ -274,7 +273,7 @@ sub switch_to_shadow_db {
my $class = shift;
if (!$_dbh_shadow) {
- if (Param('shadowdb')) {
+ if (Bugzilla->params->{'shadowdb'}) {
$_dbh_shadow = Bugzilla::DB::connect_shadow();
} else {
$_dbh_shadow = $_dbh_main;
@@ -329,7 +328,7 @@ sub _cleanup {
# When we support transactions, need to ->rollback here
$_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_shadow;
undef $_dbh;
@@ -337,6 +336,7 @@ sub _cleanup {
sub _load_param_values {
my %params;
+ my $datadir = bz_locations()->{'datadir'};
if (-e "$datadir/params") {
# Note that checksetup.pl sets file permissions on '$datadir/params'
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index aa5ad5a83..84f6ebd4b 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -30,10 +30,6 @@ package Bugzilla::Bug;
use strict;
-use vars qw(@legal_platform
- @legal_priority @legal_severity @legal_opsys @legal_bug_status
- @settable_resolution);
-
use CGI::Carp qw(fatalsToBrowser);
use Bugzilla::Attachment;
@@ -651,8 +647,6 @@ sub choices {
return $self->{'choices'} if exists $self->{'choices'};
return {} if $self->{'error'};
- &::GetVersionTable();
-
$self->{'choices'} = {};
$self->{prod_obj} ||= new Bugzilla::Product({name => $self->{product}});
@@ -665,25 +659,41 @@ sub choices {
}
# Hack - this array contains "". See bug 106589.
- my @res = grep ($_, @::settable_resolution);
+ my @res = grep ($_, @{settable_resolutions()});
$self->{'choices'} =
{
'product' => \@prodlist,
- 'rep_platform' => \@::legal_platform,
- 'priority' => \@::legal_priority,
- 'bug_severity' => \@::legal_severity,
- 'op_sys' => \@::legal_opsys,
- 'bug_status' => \@::legal_bug_status,
- 'resolution' => \@res,
- 'component' => [map($_->name, @{$self->{prod_obj}->components})],
- 'version' => [map($_->name, @{$self->{prod_obj}->versions})],
+ 'rep_platform' => get_legal_field_values('rep_platform'),
+ 'priority' => get_legal_field_values('priority'),
+ 'bug_severity' => get_legal_field_values('bug_severity'),
+ 'op_sys' => get_legal_field_values('op_sys'),
+ 'bug_status' => get_legal_field_values('bug_status'),
+ 'resolution' => \@res,
+ 'component' => [map($_->name, @{$self->{prod_obj}->components})],
+ 'version' => [map($_->name, @{$self->{prod_obj}->versions})],
'target_milestone' => [map($_->name, @{$self->{prod_obj}->milestones})],
};
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
# other Bug fields in addition to this, just create a new Bug with
# the alias.
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 2c6f6af3e..ef432c1e6 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -102,11 +102,6 @@ END
# This hash usually comes from the "mailrecipients" var in a template call.
sub Send {
my ($id, $forced) = (@_);
-
- # This only works in a sub. Probably something to do with the
- # require abuse we do.
- &::GetVersionTable();
-
return ProcessOneBug($id, $forced);
}
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm
index ca062f9d3..688878b19 100644
--- a/Bugzilla/CGI.pm
+++ b/Bugzilla/CGI.pm
@@ -40,7 +40,6 @@ use CGI::Carp qw(fatalsToBrowser);
use Bugzilla::Error;
use Bugzilla::Util;
-use Bugzilla::Config;
# We need to disable output buffering - see bug 179174
$| = 1;
@@ -79,11 +78,14 @@ sub new {
$self->{Bugzilla_cookie_list} = [];
# Send appropriate charset
- $self->charset(Param('utf8') ? 'UTF-8' : '');
+ $self->charset(Bugzilla->params->{'utf8'} ? 'UTF-8' : '');
# Redirect to SSL if required
- if (Param('sslbase') ne '' and Param('ssl') eq 'always' and i_am_cgi()) {
- $self->require_https(Param('sslbase'));
+ if (Bugzilla->params->{'sslbase'} ne ''
+ && Bugzilla->params->{'ssl'} eq 'always'
+ && i_am_cgi())
+ {
+ $self->require_https(Bugzilla->params->{'sslbase'});
}
# Check for errors
@@ -221,8 +223,9 @@ sub send_cookie {
}
# Add the default path and the domain in.
- $paramhash{'-path'} = Param('cookiepath');
- $paramhash{'-domain'} = Param('cookiedomain') if Param('cookiedomain');
+ $paramhash{'-path'} = Bugzilla->params->{'cookiepath'};
+ $paramhash{'-domain'} = Bugzilla->params->{'cookiedomain'}
+ if Bugzilla->params->{'cookiedomain'};
# Move the param list back into an array for the call to cookie().
foreach (keys(%paramhash)) {
diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm
index a04bbfe8c..3f5b788c2 100644
--- a/Bugzilla/Config.pm
+++ b/Bugzilla/Config.pm
@@ -112,19 +112,20 @@ use vars qw(@param_list);
do $localconfig;
my %params;
# Load in the param definitions
-foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) {
- $item =~ m#/([^/]+)\.pm$#;
- my $module = $1;
- next if ($module eq 'Common');
- require "Bugzilla/Config/$module.pm";
- my @new_param_list = "Bugzilla::Config::$module"->get_param_list();
- foreach my $item (@new_param_list) {
- $params{$item->{'name'}} = $item;
+sub _load_params {
+ foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) {
+ $item =~ m#/([^/]+)\.pm$#;
+ my $module = $1;
+ next if ($module eq 'Common');
+ require "Bugzilla/Config/$module.pm";
+ my @new_param_list = "Bugzilla::Config::$module"->get_param_list();
+ foreach my $item (@new_param_list) {
+ $params{$item->{'name'}} = $item;
+ }
+ push(@parampanels, $module);
+ push(@param_list, @new_param_list);
}
- push(@parampanels, $module);
- push(@param_list, @new_param_list);
}
-
# END INIT CODE
# Subroutines go here
@@ -132,6 +133,7 @@ foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) {
sub Param {
my ($param) = @_;
+ _load_params unless %params;
my %param_values = %{Bugzilla->params};
# By this stage, the param must be in the hash
@@ -153,6 +155,7 @@ sub Param {
sub SetParam {
my ($name, $value) = @_;
+ _load_params unless %params;
die "Unknown param $name" unless (exists $params{$name});
my $entry = $params{$name};
@@ -176,7 +179,6 @@ sub UpdateParams {
# Note that this isn't particularly 'clean' in terms of separating
# the backend code (ie this) from the actual params.
# We don't care about that, though
-
my $param = Bugzilla->params;
# Old Bugzilla versions stored the version number in the params file
@@ -239,6 +241,7 @@ sub UpdateParams {
# --- DEFAULTS FOR NEW PARAMS ---
+ _load_params unless %params;
foreach my $item (@param_list) {
my $name = $item->{'name'};
$param->{$name} = $item->{'default'} unless exists $param->{$name};
diff --git a/Bugzilla/Config/BugFields.pm b/Bugzilla/Config/BugFields.pm
index 17b79941d..ef0f340f1 100644
--- a/Bugzilla/Config/BugFields.pm
+++ b/Bugzilla/Config/BugFields.pm
@@ -34,11 +34,18 @@ package Bugzilla::Config::BugFields;
use strict;
use Bugzilla::Config::Common;
+use Bugzilla::Field;
$Bugzilla::Config::BugFields::sortkey = "04";
sub get_param_list {
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 = (
{
name => 'useclassification',
@@ -85,23 +92,23 @@ sub get_param_list {
{
name => 'defaultpriority',
type => 's',
- choices => \@::legal_priority,
- default => $::legal_priority[-1],
+ choices => \@legal_priorities,
+ default => $legal_priorities[-1],
checker => \&check_priority
},
{
name => 'defaultseverity',
type => 's',
- choices => \@::legal_severity,
- default => $::legal_severity[-1],
+ choices => \@legal_severities,
+ default => $legal_severities[-1],
checker => \&check_severity
},
{
name => 'defaultplatform',
type => 's',
- choices => ['', @::legal_platform],
+ choices => ['', @legal_platforms],
default => '',
checker => \&check_platform
},
@@ -109,7 +116,7 @@ sub get_param_list {
{
name => 'defaultopsys',
type => 's',
- choices => ['', @::legal_opsys],
+ choices => ['', @legal_OS],
default => '',
checker => \&check_opsys
} );
diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm
index 665b889f3..3e6e22a57 100644
--- a/Bugzilla/Config/Common.pm
+++ b/Bugzilla/Config/Common.pm
@@ -29,34 +29,15 @@
# 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;
use strict;
use Socket;
-use Bugzilla::Config qw(:DEFAULT $templatedir $webdotdir);
use Bugzilla::Util;
use Bugzilla::Constants;
+use Bugzilla::Field;
use base qw(Exporter);
@Bugzilla::Config::Common::EXPORT =
@@ -132,40 +113,40 @@ sub check_sslbase {
sub check_priority {
my ($value) = (@_);
- &::GetVersionTable();
- if (lsearch(\@::legal_priority, $value) < 0) {
+ my $legal_priorities = get_legal_field_values('priority');
+ if (lsearch($legal_priorities, $value) < 0) {
return "Must be a legal priority value: one of " .
- join(", ", @::legal_priority);
+ join(", ", @$legal_priorities);
}
return "";
}
sub check_severity {
my ($value) = (@_);
- &::GetVersionTable();
- if (lsearch(\@::legal_severity, $value) < 0) {
+ my $legal_severities = get_legal_field_values('bug_severity');
+ if (lsearch($legal_severities, $value) < 0) {
return "Must be a legal severity value: one of " .
- join(", ", @::legal_severity);
+ join(", ", @$legal_severities);
}
return "";
}
sub check_platform {
my ($value) = (@_);
- &::GetVersionTable();
- if (lsearch(['', @::legal_platform], $value) < 0) {
+ my $legal_platforms = get_legal_field_values('rep_platform');
+ if (lsearch(['', @$legal_platforms], $value) < 0) {
return "Must be empty or a legal platform value: one of " .
- join(", ", @::legal_platform);
+ join(", ", @$legal_platforms);
}
return "";
}
sub check_opsys {
my ($value) = (@_);
- &::GetVersionTable();
- if (lsearch(['', @::legal_opsys], $value) < 0) {
+ my $legal_OS = get_legal_field_values('op_sys');
+ if (lsearch(['', @$legal_OS], $value) < 0) {
return "Must be empty or a legal operating system value: one of " .
- join(", ", @::legal_opsys);
+ join(", ", @$legal_OS);
}
return "";
}
@@ -177,7 +158,7 @@ sub check_shadowdb {
return "";
}
- if (!Param('shadowdbhost')) {
+ if (!Bugzilla->params->{'shadowdbhost'}) {
return "You need to specify a host when using a shadow database";
}
@@ -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.";
}
# Check .htaccess allows access to generated images
+ my $webdotdir = bz_locations()->{'webdotdir'};
if(-e "$webdotdir/.htaccess") {
open HTACCESS, "$webdotdir/.htaccess";
if(! grep(/ \\\.png\$/,<HTACCESS>)) {
@@ -259,8 +241,8 @@ sub check_user_verify_class {
} elsif ($class eq 'LDAP') {
eval "require Net::LDAP";
return "Error requiring Net::LDAP: '$@'" if $@;
- return "LDAP servername is missing" unless Param("LDAPserver");
- return "LDAPBaseDN is empty" unless Param("LDAPBaseDN");
+ return "LDAP servername is missing" unless Bugzilla->params->{"LDAPserver"};
+ return "LDAPBaseDN is empty" unless Bugzilla->params->{"LDAPBaseDN"};
} else {
return "Unknown user_verify_class '$class' in check_user_verify_class";
}
@@ -282,6 +264,7 @@ sub check_languages {
if(!scalar(@languages)) {
return "You need to specify a language tag."
}
+ my $templatedir = bz_locations()->{'templatedir'};
foreach my $language (@languages) {
if( ! -d "$templatedir/$language/custom"
&& ! -d "$templatedir/$language/default") {
diff --git a/Bugzilla/Config/L10n.pm b/Bugzilla/Config/L10n.pm
index 6fed0ed70..957dce786 100644
--- a/Bugzilla/Config/L10n.pm
+++ b/Bugzilla/Config/L10n.pm
@@ -35,7 +35,7 @@ use strict;
use File::Spec; # for find_languages
-use Bugzilla::Config qw($templatedir);
+use Bugzilla::Constants;
use Bugzilla::Config::Common;
$Bugzilla::Config::L10n::sortkey = "08";
@@ -62,7 +62,8 @@ sub get_param_list {
sub find_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)) {
next unless $dir =~ /^([a-z-]+)$/i;
my $lang = $1;
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 0c451c8c3..0eeb9be66 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -33,6 +33,7 @@ use strict;
use base qw(Exporter);
@Bugzilla::Constants::EXPORT = qw(
+ bz_locations
CONTROLMAPNA
CONTROLMAPSHOWN
CONTROLMAPDEFAULT
@@ -278,8 +279,6 @@ use constant FIELD_TYPE_FREETEXT => 1;
use constant BUG_STATE_OPEN => ('NEW', 'REOPENED', 'ASSIGNED',
'UNCONFIRMED');
-1;
-
# Data about what we require for different databases.
use constant DB_MODULE => {
'mysql' => {db => 'Bugzilla::DB::Mysql', db_version => '4.0.14',
@@ -289,3 +288,48 @@ use constant DB_MODULE => {
dbd => 'DBD::Pg', dbd_version => '1.45',
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;
diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm
index d23e68d78..5498f7670 100644
--- a/Bugzilla/Error.pm
+++ b/Bugzilla/Error.pm
@@ -26,7 +26,6 @@ use base qw(Exporter);
@Bugzilla::Error::EXPORT = qw(ThrowCodeError ThrowTemplateError ThrowUserError);
-use Bugzilla::Config qw($datadir);
use Bugzilla::Constants;
use Bugzilla::Util;
use Date::Format;
@@ -42,6 +41,7 @@ sub _throw_error {
# and the transaction is rolled back (if supported)
Bugzilla->dbh->bz_unlock_tables(UNLOCK_ABORT);
+ my $datadir = bz_locations()->{'datadir'};
# If a writable $datadir/errorlog exists, log error details there.
if (-w "$datadir/errorlog") {
require Data::Dumper;
@@ -115,9 +115,9 @@ sub ThrowTemplateError {
# Try a template first; but if this one fails too, fall back
# on plain old print statements.
if (!$template->process("global/code-error.html.tmpl", $vars)) {
- my $maintainer = Bugzilla::Config::Param('maintainer');
- my $error = Bugzilla::Util::html_quote($vars->{'template_error_msg'});
- my $error2 = Bugzilla::Util::html_quote($template->error());
+ my $maintainer = Bugzilla->params->{'maintainer'};
+ my $error = html_quote($vars->{'template_error_msg'});
+ my $error2 = html_quote($template->error());
print <<END;
<tt>
<p>
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index b6424f3df..2118d41ac 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -70,7 +70,7 @@ package Bugzilla::Field;
use strict;
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::Constants;
@@ -280,6 +280,36 @@ sub match {
=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
=over
@@ -288,15 +318,17 @@ sub match {
Description: Makes sure the field $name is defined and its $value
is non empty. If @legal_values is defined, this routine
- also checks whether its value is one of the legal values
- associated with this field. If the test is successful,
+ checks whether its value is one of the legal values
+ 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
is thrown (by default), unless $no_warn is true, in which
case the function returns 0.
Params: $name - the field name
$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
Returns: 1 on success; 0 on failure if $no_warn is true (else an
@@ -310,17 +342,21 @@ sub check_field {
my ($name, $value, $legalsRef, $no_warn) = @_;
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)
|| 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.
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 });
+ my $field = new Bugzilla::Field($name);
+ my $field_desc = $field ? $field->description : $name;
+ ThrowCodeError('illegal_field', { field => $field_desc });
}
return 1;
}
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index da217c43d..3e28b6d8e 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -115,8 +115,6 @@ sub init {
my $dbh = Bugzilla->dbh;
- &::GetVersionTable();
-
# First, deal with all the old hard-coded non-chart-based poop.
if (grep(/map_assigned_to/, @$fieldsref)) {
push @supptables, "INNER JOIN profiles AS map_assigned_to " .
@@ -182,25 +180,26 @@ sub init {
# into their equivalent lists of open and closed statuses.
if ($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__")
{
$params->delete('bug_status');
}
elsif ($bug_statuses[0] eq '__open__') {
$params->param('bug_status', map(is_open_state($_) ? $_ : undef,
- @::legal_bug_status));
+ @legal_statuses));
}
elsif ($bug_statuses[0] eq "__closed__") {
$params->param('bug_status', map(is_open_state($_) ? undef : $_,
- @::legal_bug_status));
+ @legal_statuses));
}
}
if ($params->param('resolution')) {
my @resolutions = $params->param('resolution');
-
- if (scalar(@resolutions) == scalar(@::legal_resolution)) {
+ my $legal_resolutions = get_legal_field_values('resolution');
+ if (scalar(@resolutions) == scalar(@$legal_resolutions)) {
$params->delete('resolution');
}
}
@@ -924,7 +923,6 @@ sub init {
},
"^keywords,(?!changed)" => sub {
- &::GetVersionTable();
my @list;
my $table = "keywords_$chartid";
foreach my $value (split(/[\s,]+/, $v)) {
diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm
index 69eaf8dcc..19bc6738c 100644
--- a/Bugzilla/Search/Quicksearch.pm
+++ b/Bugzilla/Search/Quicksearch.pm
@@ -28,6 +28,7 @@ use Bugzilla::Error;
use Bugzilla::Constants;
use Bugzilla::Keyword;
use Bugzilla::Bug;
+use Bugzilla::Field;
use base qw(Exporter);
@Bugzilla::Search::Quicksearch::EXPORT = qw(quicksearch);
@@ -144,8 +145,8 @@ sub quicksearch {
}
# It's no alias either, so it's a more complex query.
-
- &::GetVersionTable();
+ my $legal_statuses = get_legal_field_values('bug_status');
+ my $legal_resolutions = get_legal_field_values('resolution');
# Globally translate " AND ", " OR ", " NOT " to space, pipe, dash.
$searchstring =~ s/\s+AND\s+/ /g;
@@ -158,12 +159,12 @@ sub quicksearch {
my @closedStates;
my (%states, %resolutions);
- foreach (@::legal_bug_status) {
+ foreach (@$legal_statuses) {
push(@closedStates, $_) unless is_open_state($_);
}
foreach (@openStates) { $states{$_} = 1 }
if ($words[0] eq 'ALL') {
- foreach (@::legal_bug_status) { $states{$_} = 1 }
+ foreach (@$legal_statuses) { $states{$_} = 1 }
shift @words;
}
elsif ($words[0] eq 'OPEN') {
@@ -175,7 +176,7 @@ sub quicksearch {
\%resolutions,
[split(/,/, substr($words[0], 1))],
\@closedStates,
- \@::legal_resolution)) {
+ $legal_resolutions)) {
shift @words;
# Allowing additional resolutions means we need to keep
# the "no resolution" resolution.
@@ -191,8 +192,8 @@ sub quicksearch {
if (matchPrefixes(\%states,
\%resolutions,
[split(/,/, $words[0])],
- \@::legal_bug_status,
- \@::legal_resolution)) {
+ $legal_statuses,
+ $legal_resolutions)) {
shift @words;
}
else {
@@ -292,7 +293,7 @@ sub quicksearch {
}
# Severity
elsif (grep({lc($word) eq substr($_, 0, 3)}
- @::legal_severity)) {
+ @{get_legal_field_values('bug_severity')})) {
addChart('bug_severity', 'substring',
$word, $negate);
}
diff --git a/buglist.cgi b/buglist.cgi
index 570ef116e..8465cae32 100755
--- a/buglist.cgi
+++ b/buglist.cgi
@@ -42,15 +42,11 @@ use Bugzilla::User;
use Bugzilla::Bug;
use Bugzilla::Product;
use Bugzilla::Keyword;
+use Bugzilla::Field;
# Include the Bugzilla CGI and general utility library.
require "globals.pl";
-use vars qw(@legal_platform
- @legal_priority
- @legal_severity
- @settable_resolution);
-
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
@@ -90,7 +86,6 @@ if ($dotweak) {
|| ThrowUserError("auth_failure", {group => "editbugs",
action => "modify",
object => "multiple_bugs"});
- GetVersionTable();
}
# Hack to support legacy applications that think the RDF ctype is at format=rdf.
@@ -1042,11 +1037,11 @@ if ($dotweak) {
$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count();
$vars->{'products'} = Bugzilla->user->get_enterable_products;
- $vars->{'platforms'} = \@::legal_platform;
- $vars->{'op_sys'} = \@::legal_opsys;
- $vars->{'priorities'} = \@::legal_priority;
- $vars->{'severities'} = \@::legal_severity;
- $vars->{'resolutions'} = \@::settable_resolution;
+ $vars->{'platforms'} = get_legal_field_values('rep_platform');
+ $vars->{'op_sys'} = get_legal_field_values('op_sys');
+ $vars->{'priorities'} = get_legal_field_values('priority');
+ $vars->{'severities'} = get_legal_field_values('bug_severity');
+ $vars->{'resolutions'} = Bugzilla::Bug->settable_resolutions;
$vars->{'unconfirmedstate'} = 'UNCONFIRMED';
diff --git a/colchange.cgi b/colchange.cgi
index 72ce01f44..cf9e14977 100755
--- a/colchange.cgi
+++ b/colchange.cgi
@@ -33,8 +33,6 @@ require "globals.pl";
Bugzilla->login();
-GetVersionTable();
-
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
diff --git a/collectstats.pl b/collectstats.pl
index 4d000f0c1..ca37c0b3c 100755
--- a/collectstats.pl
+++ b/collectstats.pl
@@ -52,8 +52,6 @@ if (chdir("graphs")) {
chdir("..");
}
-GetVersionTable();
-
# Let Throw*Error() work correctly outside a web browser.
Bugzilla->batch(1);
Bugzilla->switch_to_shadow_db();
diff --git a/config.cgi b/config.cgi
index ed16c28a8..6ed57bd85 100755
--- a/config.cgi
+++ b/config.cgi
@@ -35,19 +35,7 @@ use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Keyword;
use Bugzilla::Bug;
-
-# 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.
+use Bugzilla::Field;
my $user = Bugzilla->login(LOGIN_OPTIONAL);
@@ -57,18 +45,15 @@ if (Param('requirelogin') && !$user->id) {
display_data();
}
-# Retrieve this installation's configuration.
-GetVersionTable();
-
# Pass a bunch of Bugzilla configuration to the templates.
my $vars = {};
-$vars->{'priority'} = \@::legal_priority;
-$vars->{'severity'} = \@::legal_severity;
-$vars->{'platform'} = \@::legal_platform;
-$vars->{'op_sys'} = \@::legal_opsys;
+$vars->{'priority'} = get_legal_field_values('priority');
+$vars->{'severity'} = get_legal_field_values('bug_severity');
+$vars->{'platform'} = get_legal_field_values('rep_platform');
+$vars->{'op_sys'} = get_legal_field_values('op_sys');
$vars->{'keyword'} = [map($_->name, Bugzilla::Keyword->get_all)];
-$vars->{'resolution'} = \@::legal_resolution;
-$vars->{'status'} = \@::legal_bug_status;
+$vars->{'resolution'} = get_legal_field_values('resolution');
+$vars->{'status'} = get_legal_field_values('bug_status');
# Include a list of product objects.
$vars->{'products'} = $user->get_selectable_products;
@@ -77,7 +62,7 @@ $vars->{'products'} = $user->get_selectable_products;
# be made part of the configuration.
my @open_status;
my @closed_status;
-foreach my $status (@::legal_bug_status) {
+foreach my $status (@{$vars->{'status'}}) {
is_open_state($status) ? push(@open_status, $status)
: push(@closed_status, $status);
}
diff --git a/docs/xml/customization.xml b/docs/xml/customization.xml
index f7a08da0d..aefacda67 100644
--- a/docs/xml/customization.xml
+++ b/docs/xml/customization.xml
@@ -753,32 +753,6 @@
ask in the newsgroup.
</para>
</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">
<title>MySQL Bugzilla Database Introduction</title>
diff --git a/duplicates.cgi b/duplicates.cgi
index 69ba8299b..5264e1e14 100755
--- a/duplicates.cgi
+++ b/duplicates.cgi
@@ -54,8 +54,6 @@ if (defined $cgi->param('ctype') && $cgi->param('ctype') eq "xul") {
my $template = Bugzilla->template;
my $vars = {};
-GetVersionTable();
-
# collectstats.pl uses duplicates.cgi to generate the RDF duplicates stats.
# However, this conflicts with requirelogin if it's enabled; so we make
# logging-in optional if we are running from the command line.
diff --git a/editclassifications.cgi b/editclassifications.cgi
index 352d7816b..ce82ccb97 100755
--- a/editclassifications.cgi
+++ b/editclassifications.cgi
@@ -115,9 +115,6 @@ if ($action eq 'new') {
$dbh->do("INSERT INTO classifications (name, description)
VALUES (?, ?)", undef, ($class_name, $description));
- # Make versioncache flush
- unlink "$datadir/versioncache";
-
$vars->{'classification'} = $class_name;
LoadTemplate($action);
@@ -173,8 +170,6 @@ if ($action eq 'delete') {
$dbh->bz_unlock_tables();
- unlink "$datadir/versioncache";
-
$vars->{'classification'} = $classification;
LoadTemplate($action);
@@ -222,10 +217,8 @@ if ($action eq 'update') {
trick_taint($class_name);
$dbh->do("UPDATE classifications SET name = ? WHERE id = ?",
undef, ($class_name, $class_old->id));
-
- $vars->{'updated_classification'} = 1;
- unlink "$datadir/versioncache";
+ $vars->{'updated_classification'} = 1;
}
if ($description ne $class_old->description) {
@@ -235,8 +228,6 @@ if ($action eq 'update') {
($description, $class_old->id));
$vars->{'updated_description'} = 1;
-
- unlink "$datadir/versioncache";
}
$dbh->bz_unlock_tables();
diff --git a/editcomponents.cgi b/editcomponents.cgi
index 30caaf5f3..e063c1b10 100755
--- a/editcomponents.cgi
+++ b/editcomponents.cgi
@@ -175,8 +175,6 @@ if ($action eq 'new') {
# Insert default charting queries for this product.
# If they aren't using charting, this won't do any harm.
- GetVersionTable();
-
my @series;
my $prodcomp = "&product=" . url_quote($product->name) .
@@ -208,9 +206,6 @@ if ($action eq 'new') {
$series->writeToDatabase();
}
- # Make versioncache flush
- unlink "$datadir/versioncache";
-
$component =
new Bugzilla::Component({product_id => $product->id,
name => $comp_name});
@@ -280,8 +275,6 @@ if ($action eq 'delete') {
$dbh->bz_unlock_tables();
- unlink "$datadir/versioncache";
-
$vars->{'comp'} = $component;
$vars->{'product'} = $product;
$template->process("admin/components/deleted.html.tmpl", $vars)
@@ -367,7 +360,6 @@ if ($action eq 'update') {
$dbh->do("UPDATE components SET name = ? WHERE id = ?",
undef, ($comp_name, $component_old->id));
- unlink "$datadir/versioncache";
$vars->{'updated_name'} = 1;
}
diff --git a/editkeywords.cgi b/editkeywords.cgi
index e98be6306..b53aebb3e 100755
--- a/editkeywords.cgi
+++ b/editkeywords.cgi
@@ -152,9 +152,6 @@ if ($action eq 'new') {
(id, name, description) VALUES (?, ?, ?)',
undef, ($newid, $name, $description));
- # Make versioncache flush
- unlink "$datadir/versioncache";
-
print $cgi->header();
$vars->{'name'} = $name;
@@ -226,9 +223,6 @@ if ($action eq 'update') {
$dbh->do('UPDATE keyworddefs SET name = ?, description = ?
WHERE id = ?', undef, ($name, $description, $id));
- # Make versioncache flush
- unlink "$datadir/versioncache";
-
print $cgi->header();
$vars->{'name'} = $name;
@@ -267,9 +261,6 @@ if ($action eq 'delete') {
$dbh->do('DELETE FROM keywords WHERE keywordid = ?', undef, $id);
$dbh->do('DELETE FROM keyworddefs WHERE id = ?', undef, $id);
- # Make versioncache flush
- unlink "$datadir/versioncache";
-
print $cgi->header();
$vars->{'name'} = $name;
diff --git a/editmilestones.cgi b/editmilestones.cgi
index 8d9cbe973..8e2a6e3f4 100755
--- a/editmilestones.cgi
+++ b/editmilestones.cgi
@@ -144,9 +144,6 @@ if ($action eq 'new') {
VALUES ( ?, ?, ? )',
undef, $milestone_name, $product->id, $sortkey);
- # Make versioncache flush
- unlink "$datadir/versioncache";
-
$milestone = new Bugzilla::Milestone($product->id,
$milestone_name);
$vars->{'milestone'} = $milestone;
@@ -227,8 +224,6 @@ if ($action eq 'delete') {
$dbh->do("DELETE FROM milestones WHERE product_id = ? AND value = ?",
undef, ($product->id, $milestone->name));
- unlink "$datadir/versioncache";
-
$template->process("admin/milestones/deleted.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@@ -292,7 +287,6 @@ if ($action eq 'update') {
$product->id,
$milestone_old->name);
- unlink "$datadir/versioncache";
$vars->{'updated_sortkey'} = 1;
}
@@ -337,8 +331,6 @@ if ($action eq 'update') {
$product->id,
$milestone_old->name);
- unlink "$datadir/versioncache";
-
$vars->{'updated_name'} = 1;
}
diff --git a/editparams.cgi b/editparams.cgi
index 57058e7ad..487208b47 100755
--- a/editparams.cgi
+++ b/editparams.cgi
@@ -49,14 +49,12 @@ my $current_panel = $cgi->param('section') || 'core';
$current_panel =~ /^([A-Za-z0-9_-]+)$/;
$current_panel = $1;
-GetVersionTable();
-
my $current_module;
my @panels = ();
foreach my $panel (@parampanels) {
next if ($panel eq 'Common');
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),
current => ($current_panel eq lc($panel)) ? 1 : 0,
param_list => \@module_param_list,
@@ -70,7 +68,7 @@ $vars->{panels} = \@panels;
if ($action eq 'save' && $current_module) {
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) {
my $name = $i->{'name'};
@@ -128,7 +126,6 @@ if ($action eq 'save' && $current_module) {
$vars->{'param_changed'} = \@changes;
WriteParams();
- unlink "$datadir/versioncache";
}
$template->process("admin/params/editparams.html.tmpl", $vars)
diff --git a/editproducts.cgi b/editproducts.cgi
index b21ceb8fd..46b3a0145 100755
--- a/editproducts.cgi
+++ b/editproducts.cgi
@@ -45,10 +45,7 @@ use Bugzilla::Classification;
use Bugzilla::Milestone;
use Bugzilla::Group;
use Bugzilla::User;
-
-# 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);
+use Bugzilla::Field;
#
# Preliminary checks:
@@ -273,8 +270,7 @@ if ($action eq 'new') {
if ($cgi->param('createseries')) {
# Insert default charting queries for this product.
# If they aren't using charting, this won't do any harm.
- GetVersionTable();
-
+ #
# $open_name and $product are sqlquoted by the series code
# and never used again here, so we can trick_taint them.
my $open_name = $cgi->param('open_name');
@@ -283,12 +279,12 @@ if ($action eq 'new') {
my @series;
# 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,
"bug_status=" . url_quote($bug_status)]);
}
- foreach my $resolution (@::legal_resolution) {
+ foreach my $resolution (@{get_legal_field_values('resolution')}) {
next if !$resolution;
push(@series, [$resolution, "resolution=" .url_quote($resolution)]);
}
@@ -309,11 +305,8 @@ if ($action eq 'new') {
$series->writeToDatabase();
}
}
- # Make versioncache flush
- unlink "$datadir/versioncache";
-
$vars->{'product'} = $product;
-
+
$template->process("admin/products/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@@ -417,8 +410,6 @@ if ($action eq 'delete') {
$dbh->bz_unlock_tables();
- unlink "$datadir/versioncache";
-
$template->process("admin/products/deleted.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@@ -878,7 +869,6 @@ if ($action eq 'update') {
}
$dbh->bz_unlock_tables();
- unlink "$datadir/versioncache";
my $product = new Bugzilla::Product({name => $product_name});
diff --git a/editvalues.cgi b/editvalues.cgi
index b0a1fbb71..2da48eed2 100755
--- a/editvalues.cgi
+++ b/editvalues.cgi
@@ -217,8 +217,6 @@ if ($action eq 'new') {
VALUES ( ?, ? )");
$sth->execute($value, $sortkey);
- unlink "$datadir/versioncache";
-
$vars->{'value'} = $value;
$vars->{'field'} = $field;
$template->process("admin/fieldvalues/created.html.tmpl",
@@ -287,8 +285,6 @@ if ($action eq 'delete') {
$dbh->bz_unlock_tables();
- unlink "$datadir/versioncache";
-
$vars->{'value'} = $value;
$vars->{'field'} = $field;
$template->process("admin/fieldvalues/deleted.html.tmpl",
@@ -354,7 +350,6 @@ if ($action eq 'update') {
$dbh->do("UPDATE $field SET sortkey = ? WHERE value = ?",
undef, $sortkey, $valueold);
- unlink "$datadir/versioncache";
$vars->{'updated_sortkey'} = 1;
$vars->{'sortkey'} = $sortkey;
}
@@ -377,8 +372,6 @@ if ($action eq 'update') {
$dbh->do("UPDATE $field SET value = ? WHERE value = ?",
undef, $value, $valueold);
- unlink "$datadir/versioncache";
-
$vars->{'updated_value'} = 1;
}
@@ -387,13 +380,12 @@ if ($action eq 'update') {
# If the old value was the default value for the field,
# update data/params accordingly.
# 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
&& $valueold eq Param($defaults{$field}))
{
SetParam($defaults{$field}, $value);
WriteParams();
- unlink "$datadir/versioncache";
$vars->{'default_value_updated'} = 1;
}
diff --git a/editversions.cgi b/editversions.cgi
index c245bdb9f..c060657d2 100755
--- a/editversions.cgi
+++ b/editversions.cgi
@@ -144,9 +144,6 @@ if ($action eq 'new') {
$dbh->do("INSERT INTO versions (value, product_id)
VALUES (?, ?)", undef, ($version_name, $product->id));
- # Make versioncache flush
- unlink "$datadir/versioncache";
-
$version = new Bugzilla::Version($product->id, $version_name);
$vars->{'version'} = $version;
$vars->{'product'} = $product;
@@ -201,8 +198,6 @@ if ($action eq 'delete') {
$dbh->do("DELETE FROM versions WHERE product_id = ? AND value = ?",
undef, ($product->id, $version->name));
- unlink "$datadir/versioncache";
-
$vars->{'version'} = $version;
$vars->{'product'} = $product;
@@ -279,8 +274,6 @@ if ($action eq 'update') {
WHERE product_id = ? AND value = ?", undef,
($version_name, $product->id, $version_old->name));
- unlink "$datadir/versioncache";
-
$vars->{'updated_name'} = 1;
}
diff --git a/enter_bug.cgi b/enter_bug.cgi
index 5b5f3cf77..54b3f818b 100755
--- a/enter_bug.cgi
+++ b/enter_bug.cgi
@@ -46,15 +46,9 @@ use Bugzilla::Product;
use Bugzilla::Classification;
use Bugzilla::Keyword;
use Bugzilla::Token;
+use Bugzilla::Field;
require "globals.pl";
-use vars qw(
- @legal_opsys
- @legal_platform
- @legal_priority
- @legal_severity
-);
-
my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cloned_bug;
@@ -312,8 +306,6 @@ if ($cloned_bug_id) {
$cloned_bug = new Bugzilla::Bug($cloned_bug_id, $user->id);
}
-GetVersionTable();
-
if (scalar(@{$product->components}) == 1) {
# Only one component; just pick it.
$cgi->param('component', $product->components->[0]->name);
@@ -323,10 +315,10 @@ my %default;
$vars->{'product'} = $product;
-$vars->{'priority'} = \@legal_priority;
-$vars->{'bug_severity'} = \@legal_severity;
-$vars->{'rep_platform'} = \@legal_platform;
-$vars->{'op_sys'} = \@legal_opsys;
+$vars->{'priority'} = get_legal_field_values('priority');
+$vars->{'bug_severity'} = get_legal_field_values('bug_severity');
+$vars->{'rep_platform'} = get_legal_field_values('rep_platform');
+$vars->{'op_sys'} = get_legal_field_values('op_sys');
$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count();
diff --git a/globals.pl b/globals.pl
index a1e87eec2..6af204666 100644
--- a/globals.pl
+++ b/globals.pl
@@ -39,23 +39,6 @@ use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir);
use Bugzilla::User;
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
# of globals.pl
do $localconfig;
@@ -68,88 +51,6 @@ use Date::Parse; # For str2time().
# Use standard Perl libraries for cross-platform file/directory manipulation.
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) #############
use Bugzilla;
diff --git a/importxml.pl b/importxml.pl
index dad82b17d..6faa172e3 100755
--- a/importxml.pl
+++ b/importxml.pl
@@ -86,6 +86,7 @@ use Bugzilla::User;
use Bugzilla::Util;
use Bugzilla::Constants;
use Bugzilla::Keyword;
+use Bugzilla::Field;
use MIME::Base64;
use MIME::Parser;
@@ -116,7 +117,6 @@ use constant OK_LEVEL => 3;
use constant DEBUG_LEVEL => 2;
use constant ERR_LEVEL => 1;
-GetVersionTable();
our @logs;
our @attachments;
our $bugtotal;
@@ -128,19 +128,6 @@ my ($timestamp) = $dbh->selectrow_array("SELECT NOW()");
# 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 {
return unless ($mail);
my $subject = shift;
@@ -180,27 +167,6 @@ sub Error {
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
# it can handle both attachment flags and bug flags.
sub flag_handler {
@@ -741,7 +707,7 @@ sub process_bug {
# imported is valid. If it is not we use the defaults set in the parameters.
if (defined( $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'} );
}
@@ -758,7 +724,7 @@ sub process_bug {
if (defined( $bug_fields{'priority'} )
&& check_field('priority', scalar $bug_fields{'priority'},
- \@::legal_priority, ERR_LEVEL ) )
+ undef, ERR_LEVEL ) )
{
push( @values, $bug_fields{'priority'} );
}
@@ -775,7 +741,7 @@ sub process_bug {
if (defined( $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'} );
}
@@ -792,7 +758,7 @@ sub process_bug {
if (defined( $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'} );
}
@@ -898,10 +864,10 @@ sub process_bug {
my $has_status = defined($bug_fields{'bug_status'});
my $valid_res = check_field('resolution',
scalar $bug_fields{'resolution'},
- \@::legal_resolution, ERR_LEVEL );
+ undef, ERR_LEVEL );
my $valid_status = check_field('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 $status = $bug_fields{'bug_status'} || undef;
my $resolution = $bug_fields{'resolution'} || undef;
diff --git a/post_bug.cgi b/post_bug.cgi
index de7868555..4cc00ce6b 100755
--- a/post_bug.cgi
+++ b/post_bug.cgi
@@ -39,16 +39,6 @@ use Bugzilla::Product;
use Bugzilla::Keyword;
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 $cgi = Bugzilla->cgi;
@@ -248,14 +238,12 @@ if (!Param('letsubmitterchoosepriority')) {
$cgi->param(-name => 'priority', -value => Param('defaultpriority'));
}
-GetVersionTable();
-
# Some more sanity checking
-check_field('rep_platform', scalar $cgi->param('rep_platform'), \@::legal_platform);
-check_field('bug_severity', scalar $cgi->param('bug_severity'), \@::legal_severity);
-check_field('priority', scalar $cgi->param('priority'), \@::legal_priority);
-check_field('op_sys', scalar $cgi->param('op_sys'), \@::legal_opsys);
-check_field('bug_status', scalar $cgi->param('bug_status'), ['UNCONFIRMED', 'NEW']);
+check_field('rep_platform', scalar $cgi->param('rep_platform'));
+check_field('bug_severity', scalar $cgi->param('bug_severity'));
+check_field('priority', scalar $cgi->param('priority'));
+check_field('op_sys', scalar $cgi->param('op_sys'));
+check_field('bug_status', scalar $cgi->param('bug_status'), ['UNCONFIRMED', 'NEW']);
check_field('version', scalar $cgi->param('version'),
[map($_->name, @{$product->versions})]);
check_field('target_milestone', scalar $cgi->param('target_milestone'),
diff --git a/process_bug.cgi b/process_bug.cgi
index ca72015a2..88377c78e 100755
--- a/process_bug.cgi
+++ b/process_bug.cgi
@@ -64,15 +64,6 @@ use Bugzilla::Keyword;
use Bugzilla::Flag;
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 $whoid = $user->id;
my $grouplist = $user->groups_as_string;
@@ -266,8 +257,6 @@ if ($cgi->cookie("BUGLIST") && defined $cgi->param('id')) {
$vars->{'bug_list'} = \@bug_list;
}
-GetVersionTable();
-
foreach my $field_name ('product', 'component', 'version') {
defined($cgi->param($field_name))
|| ThrowCodeError('undefined_field', { field => $field_name });
@@ -639,10 +628,10 @@ if (defined $cgi->param('id')) {
check_field('target_milestone', scalar $cgi->param('target_milestone'),
[map($_->name, @{$prod_obj->milestones})]);
}
- check_field('rep_platform', scalar $cgi->param('rep_platform'), \@::legal_platform);
- check_field('op_sys', scalar $cgi->param('op_sys'), \@::legal_opsys);
- check_field('priority', scalar $cgi->param('priority'), \@::legal_priority);
- check_field('bug_severity', scalar $cgi->param('bug_severity'), \@::legal_severity);
+ check_field('rep_platform', scalar $cgi->param('rep_platform'));
+ check_field('op_sys', scalar $cgi->param('op_sys'));
+ check_field('priority', scalar $cgi->param('priority'));
+ check_field('bug_severity', scalar $cgi->param('bug_severity'));
# Those fields only have to exist. We don't validate their value here.
foreach my $field_name ('bug_file_loc', 'short_desc', 'longdesclength') {
@@ -1173,7 +1162,7 @@ SWITCH: for ($cgi->param('knob')) {
/^(resolve|change_resolution)$/ && CheckonComment( "resolve" ) && do {
# Check here, because its the only place we require the resolution
check_field('resolution', scalar $cgi->param('resolution'),
- \@::settable_resolution);
+ Bugzilla::Bug->settable_resolutions);
# don't resolve as fixed while still unresolved blocking bugs
if (Param("noresolveonopenblockers")
diff --git a/query.cgi b/query.cgi
index b82504808..1ab53a9b8 100755
--- a/query.cgi
+++ b/query.cgi
@@ -37,15 +37,7 @@ use Bugzilla::User;
use Bugzilla::Util;
use Bugzilla::Product;
use Bugzilla::Keyword;
-
-use vars qw(
- @legal_resolution
- @legal_bug_status
- @legal_opsys
- @legal_platform
- @legal_priority
- @legal_severity
-);
+use Bugzilla::Field;
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
@@ -240,12 +232,10 @@ if (Param('usetargetmilestone')) {
$vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count();
-GetVersionTable();
-
-push @::legal_resolution, "---"; # Oy, what a hack.
-shift @::legal_resolution;
- # Another hack - this array contains "" for some reason. See bug 106589.
-$vars->{'resolution'} = \@::legal_resolution;
+my $legal_resolutions = get_legal_field_values('resolution');
+push(@$legal_resolutions, "---"); # Oy, what a hack.
+# Another hack - this array contains "" for some reason. See bug 106589.
+$vars->{'resolution'} = [grep ($_, @$legal_resolutions)];
my @chfields;
@@ -272,11 +262,11 @@ if (UserInGroup(Param('timetrackinggroup'))) {
}
@chfields = (sort(@chfields));
$vars->{'chfield'} = \@chfields;
-$vars->{'bug_status'} = \@::legal_bug_status;
-$vars->{'rep_platform'} = \@::legal_platform;
-$vars->{'op_sys'} = \@::legal_opsys;
-$vars->{'priority'} = \@::legal_priority;
-$vars->{'bug_severity'} = \@::legal_severity;
+$vars->{'bug_status'} = get_legal_field_values('bug_status');
+$vars->{'rep_platform'} = get_legal_field_values('rep_platform');
+$vars->{'op_sys'} = get_legal_field_values('op_sys');
+$vars->{'priority'} = get_legal_field_values('priority');
+$vars->{'bug_severity'} = get_legal_field_values('bug_severity');
# Boolean charts
my @fields;
diff --git a/report.cgi b/report.cgi
index 98fcb2e7f..c46361f1d 100755
--- a/report.cgi
+++ b/report.cgi
@@ -26,10 +26,9 @@ use lib ".";
require "globals.pl";
-use vars qw(@legal_opsys @legal_platform @legal_severity);
-
use Bugzilla;
use Bugzilla::Constants;
+use Bugzilla::Field;
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
@@ -48,8 +47,6 @@ if (grep(/^cmd-/, $cgi->param())) {
use Bugzilla::Search;
-GetVersionTable();
-
Bugzilla->login();
my $dbh = Bugzilla->switch_to_shadow_db();
@@ -329,12 +326,12 @@ sub get_names {
my ($names, $isnumeric, $field) = @_;
# These are all the fields we want to preserve the order of in reports.
- my %fields = ('priority' => \@::legal_priority,
- 'bug_severity' => \@::legal_severity,
- 'rep_platform' => \@::legal_platform,
- 'op_sys' => \@::legal_opsys,
- 'bug_status' => \@::legal_bug_status,
- 'resolution' => [' ', @::legal_resolution]);
+ my %fields = ('priority' => get_legal_field_values('priority'),
+ 'bug_severity' => get_legal_field_values('bug_severity'),
+ 'rep_platform' => get_legal_field_values('rep_platform'),
+ 'op_sys' => get_legal_field_values('op_sys'),
+ 'bug_status' => get_legal_field_values('bug_status'),
+ 'resolution' => [' ', @{get_legal_field_values('resolution')}]);
my $field_list = $fields{$field};
my @sorted;
diff --git a/reports.cgi b/reports.cgi
index 1181e3a81..5b043c934 100755
--- a/reports.cgi
+++ b/reports.cgi
@@ -55,8 +55,6 @@ use Bugzilla;
# to viewing reports, as well. Time to check the login in that case.
my $user = Bugzilla->login();
-GetVersionTable();
-
Bugzilla->switch_to_shadow_db();
my $cgi = Bugzilla->cgi;
diff --git a/show_bug.cgi b/show_bug.cgi
index 578b6a7a8..0efdad09e 100755
--- a/show_bug.cgi
+++ b/show_bug.cgi
@@ -54,8 +54,6 @@ if (!$cgi->param('id') && $single) {
my $format = $template->get_format("bug/show", scalar $cgi->param('format'),
scalar $cgi->param('ctype'));
-GetVersionTable();
-
my @bugs = ();
my %marks;
diff --git a/summarize_time.cgi b/summarize_time.cgi
index 527c02c9b..388c82dba 100755
--- a/summarize_time.cgi
+++ b/summarize_time.cgi
@@ -33,8 +33,6 @@ require "globals.pl";
my $template = Bugzilla->template;
my $vars = {};
-GetVersionTable();
-
#
# Date handling
#
diff --git a/userprefs.cgi b/userprefs.cgi
index 9fb9c6614..26c4d585f 100755
--- a/userprefs.cgi
+++ b/userprefs.cgi
@@ -433,8 +433,6 @@ Bugzilla->login(LOGIN_REQUIRED);
$cgi->param('Bugzilla_login', $bugzilla_login);
$cgi->param('Bugzilla_password', $bugzilla_password);
-GetVersionTable();
-
$vars->{'changes_saved'} = $cgi->param('dosave');
my $current_tab_name = $cgi->param('tab') || "account";
diff --git a/votes.cgi b/votes.cgi
index 00bcdb4ae..78b00ec1a 100755
--- a/votes.cgi
+++ b/votes.cgi
@@ -112,8 +112,6 @@ sub show_bug {
# Display all the votes for a particular user. If it's the user
# doing the viewing, give them the option to edit them too.
sub show_user {
- GetVersionTable();
-
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
@@ -253,9 +251,6 @@ sub record_votes {
############################################################################
# End Data/Security Validation
############################################################################
-
- GetVersionTable();
-
my $who = Bugzilla->user->id;
# If the user is voting for bugs, make sure they aren't overstuffing