From 2545c0950c4f0fde8f78b265217fa9f523eff7bf Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Tue, 20 Jun 2006 03:15:17 +0000 Subject: =?UTF-8?q?Bug=20304601:=20Bugzilla::Config's=20:locations=20expor?= =?UTF-8?q?ts=20need=20to=20be=20in=20their=20own=20module=20-=20Patch=20b?= =?UTF-8?q?y=20Fr=C3=A9d=C3=A9ric=20Buclin=20=20r=3Dmka?= =?UTF-8?q?nat=20for=20the=20main=20patch,=20r=3Dmyk=20for=20the=20patch?= =?UTF-8?q?=20about=20CGI.pm=20a=3Djustdave?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug 328637: Remove all legal_* versioncache arrays - Patch by Frédéric Buclin r=mkanat a=justdave Bug 110503 - Eliminate versioncache --- Bugzilla/Bug.pm | 40 +++++++++++++++++++------------ Bugzilla/BugMail.pm | 5 ---- Bugzilla/CGI.pm | 15 +++++++----- Bugzilla/Config.pm | 27 +++++++++++---------- Bugzilla/Config/BugFields.pm | 19 ++++++++++----- Bugzilla/Config/Common.pm | 53 ++++++++++++++--------------------------- Bugzilla/Config/L10n.pm | 5 ++-- Bugzilla/Constants.pm | 48 +++++++++++++++++++++++++++++++++++-- Bugzilla/Error.pm | 8 +++---- Bugzilla/Field.pm | 54 +++++++++++++++++++++++++++++++++++------- Bugzilla/Search.pm | 14 +++++------ Bugzilla/Search/Quicksearch.pm | 17 ++++++------- 12 files changed, 193 insertions(+), 112 deletions(-) (limited to 'Bugzilla') 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 # -# 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\$/,)) { @@ -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 <

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; @@ -278,6 +278,36 @@ sub match { return @fields; } +=pod + +=over + +=item C + +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. 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); } -- cgit v1.2.1