]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 304601: Bugzilla::Config's :locations exports need to be in their own module...
authorlpsolit%gmail.com <>
Tue, 20 Jun 2006 03:15:17 +0000 (03:15 +0000)
committerlpsolit%gmail.com <>
Tue, 20 Jun 2006 03:15:17 +0000 (03:15 +0000)
Bug 328637: Remove all legal_* versioncache arrays - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=justdave

Bug 110503 - Eliminate versioncache

39 files changed:
Bugzilla.pm
Bugzilla/Bug.pm
Bugzilla/BugMail.pm
Bugzilla/CGI.pm
Bugzilla/Config.pm
Bugzilla/Config/BugFields.pm
Bugzilla/Config/Common.pm
Bugzilla/Config/L10n.pm
Bugzilla/Constants.pm
Bugzilla/Error.pm
Bugzilla/Field.pm
Bugzilla/Search.pm
Bugzilla/Search/Quicksearch.pm
buglist.cgi
colchange.cgi
collectstats.pl
config.cgi
docs/xml/customization.xml
duplicates.cgi
editclassifications.cgi
editcomponents.cgi
editkeywords.cgi
editmilestones.cgi
editparams.cgi
editproducts.cgi
editvalues.cgi
editversions.cgi
enter_bug.cgi
globals.pl
importxml.pl
post_bug.cgi
process_bug.cgi
query.cgi
report.cgi
reports.cgi
show_bug.cgi
summarize_time.cgi
userprefs.cgi
votes.cgi

index fc2ef8af5ba01b7eec7c2105888f17d3df27d7c0..ea77401512685f93bff9036bde3ac7b7e00530c4 100644 (file)
@@ -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'
 
index aa5ad5a83e1103a35854082accc96e0a8e4251a2..84f6ebd4b75c52c64a12a8df79bf76eaa5191afa 100755 (executable)
@@ -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.
index 2c6f6af3e3a7388450a8fdda815a664f5d2af069..ef432c1e63ee32f19f494ab6d272790a679b2a59 100644 (file)
@@ -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);
 }
 
index ca062f9d329ecc43f0b1bf4d1de9cc9c5de21d1a..688878b19ac23485375a571d1df1d153f1d589eb 100644 (file)
@@ -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)) {
index a04bbfe8c3452a43844cd1a60ea0c81e16a4cdd0..3f5b788c2edc47ef6fe0a0fe2c0be7f5336a6bfa 100644 (file)
@@ -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};
index 17b79941d34eb48229a37eeff2978ef6c3c33a96..ef0f340f1b71124f034d37357b87a07f3a5aa14e 100644 (file)
@@ -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
   } );
index 665b889f334d255d98dcc31b446a20a6c6d1ca12..3e6e22a57b00b2294c9eb9d5f1d7a943c34484fb 100644 (file)
 #                 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") {
index 6fed0ed70cc30b0cd97db1c249efb448d6272d2c..957dce786f0456f70adf5bf510ade888299c0ff5 100644 (file)
@@ -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;
index 0c451c8c3e305de160e859ad5a0cae1d5586f0a2..0eeb9be664f1691ccf4c3b7aad7275dbc0c7f756 100644 (file)
@@ -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;
index d23e68d78ad9d4d34cd4d9bf26d63cd266adb48f..5498f76708c7bf43d50f81ee767b2f666f345467 100644 (file)
@@ -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>
index b6424f3dfc7d88719b299a83d197d3a4ce525031..2118d41acad2fe2cd3818b3019be5e615cdbcc32 100644 (file)
@@ -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;
@@ -278,6 +278,36 @@ sub match {
     return @fields;
 }
 
+=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
@@ -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;
 }
index da217c43dc34aa4e4ebb54455e224645891bcab8..3e28b6d8ecbcf55661cccebab0b6e9b7934e8fb6 100644 (file)
@@ -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)) {
index 69eaf8dcca460c40278f2812d84c22a7bdbafbfb..19bc6738c2ddb31a1be61c27e4c8f039ee4ae3e4 100644 (file)
@@ -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);
                             }
index 570ef116e7be0b8a4b5bb6aca5bb0c9165ac0eae..8465cae32e0c5340549e0360a1f62c3d541dc912 100755 (executable)
@@ -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';
 
index 72ce01f44d5e7bfa0bfc99291984f22c45d758ca..cf9e14977a553918ce9449b3342b57a8095394f9 100755 (executable)
@@ -33,8 +33,6 @@ require "globals.pl";
 
 Bugzilla->login();
 
-GetVersionTable();
-
 my $cgi = Bugzilla->cgi;
 my $template = Bugzilla->template;
 my $vars = {};
index 4d000f0c166bf05fb354f67e356727f0457b6ee8..ca37c0b3cec1badbcfe65bcd3eead6c9829a8348 100755 (executable)
@@ -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();
index ed16c28a8ab819e3abab1b80c65077fdc487bbc9..6ed57bd855c302d569e23ed71175fe22d55a898f 100755 (executable)
@@ -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);
 }
index f7a08da0dbfd33a5330f013d5a493c49811b3d68..aefacda670290c6e648c0a061c063963be54d575 100644 (file)
       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>
index 69ba8299b205229ffb199a3bf24fa0701e3267cc..5264e1e14119e93be80a186a9a900ded9a2854ba 100755 (executable)
@@ -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.
index 352d7816b9584b8f3a396ba610a7ae8927ef8f48..ce82ccb97d0cee3fe2f60770eabd198fd5d455ba 100755 (executable)
@@ -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();
index 30caaf5f3a62edfaf283158c076e5a7753b59525..e063c1b1088b950a8f76d544211f136446499cc1 100755 (executable)
@@ -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;
 
     }
index e98be63060f51330c2e058e1e5a46aa86813f29e..b53aebb3e77e2f38e8242fefef29b5994485d1f0 100755 (executable)
@@ -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;
index 8d9cbe9733b153d9701f3fc0a60e2859c4c6d0ac..8e2a6e3f40dbd6fb196edac539ff7dc79a26fdce 100755 (executable)
@@ -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;
     }
 
index 57058e7ad7ed437f05497afecdd038404ca06f27..487208b4798c354fd2c9e1ffce683e3f25a10168 100755 (executable)
@@ -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)
index b21ceb8fd8a7bae91c879700e3f4c50153750afb..46b3a01454d699816df4e7189db695605ba30532 100755 (executable)
@@ -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});
 
index b0a1fbb71d9793970fdae2579d0d69f7e74deb34..2da48eed23278dee6492e3e74891b61fdbbfc52f 100755 (executable)
@@ -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;
     }
 
index c245bdb9fdd1270bde931efe0fc4de07fbc25f5d..c060657d2aac6a277770d7267361dc1c25293c8f 100755 (executable)
@@ -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;
     }
 
index 5b5f3cf77d2fc8de8ac5499980d6fdfa6636170f..54b3f818b24878bb8d86664417f6aa1e7dd5b66b 100755 (executable)
@@ -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();
 
index a1e87eec25eee6618a3eb914e4515d3e2ec43a10..6af2046668ba27cf5c6e65aea7c5fb54b9184030 100644 (file)
@@ -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;
index dad82b17d2416ce89614172549f4435eb5e4f05a..6faa172e3e07d18a423aa3f20132073723c4ef06 100755 (executable)
@@ -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;
index de7868555b2c439afdae133da803026ccff51a95..4cc00ce6b12808b822054105ec848d40fe16ee55 100755 (executable)
@@ -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'),
index ca72015a2789938b7be9e2302ac15afe2bc23bd4..88377c78e52af70fac5617622783ee087f01b3b6 100755 (executable)
@@ -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")
index b8250480893271a0deb16f1a30b07c5c099271c1..1ab53a9b8adfd43577c8576dcef187ee4fc4c394 100755 (executable)
--- 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;
index 98fcb2e7ffd2307ee99de3d6cd97d88e4c032060..c46361f1d082c7d5e50c6e9cab9b9da77b99eb88 100755 (executable)
@@ -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;
index 1181e3a81f1ae4eba6337120cac394b0edfbb3d5..5b043c93469cf79464f51f18669dcbdca86e5ecf 100755 (executable)
@@ -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;
index 578b6a7a88040b406a1eed0d778a8640ee550bfd..0efdad09ec9439bef3a971c0f17d0597d8349b37 100755 (executable)
@@ -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;
 
index 527c02c9bfc757861aea6eb433af1045620b742e..388c82dba75f925fabca5c4510c6ae5638ff98cc 100755 (executable)
@@ -33,8 +33,6 @@ require "globals.pl";
 my $template = Bugzilla->template;
 my $vars = {};
 
-GetVersionTable();
-
 #
 # Date handling
 #
index 9fb9c6614aa1a3292a2f3241be45dac724edeb95..26c4d585fd7f175d09ba7970719905fcfe6bb1f3 100755 (executable)
@@ -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";
index 00bcdb4ae0841bcb74dbb93babb7daf9e4c092d9..78b00ec1a591f5947344758f08db600146a31f60 100755 (executable)
--- 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