diff options
-rwxr-xr-x | Bugzilla/Bug.pm | 11 | ||||
-rw-r--r-- | Bugzilla/BugMail.pm | 3 | ||||
-rw-r--r-- | Bugzilla/Constants.pm | 6 | ||||
-rw-r--r-- | Bugzilla/Search.pm | 5 | ||||
-rw-r--r-- | Bugzilla/Search/Quicksearch.pm | 6 | ||||
-rw-r--r-- | Bugzilla/Template.pm | 3 | ||||
-rwxr-xr-x | buglist.cgi | 2 | ||||
-rwxr-xr-x | checksetup.pl | 7 | ||||
-rwxr-xr-x | config.cgi | 3 | ||||
-rwxr-xr-x | editproducts.cgi | 2 | ||||
-rw-r--r-- | globals.pl | 19 | ||||
-rwxr-xr-x | importxml.pl | 2 | ||||
-rwxr-xr-x | process_bug.cgi | 8 | ||||
-rwxr-xr-x | sanitycheck.cgi | 2 | ||||
-rwxr-xr-x | showdependencygraph.cgi | 2 | ||||
-rwxr-xr-x | showdependencytree.cgi | 2 | ||||
-rwxr-xr-x | votes.cgi | 2 |
17 files changed, 44 insertions, 41 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index f297ec681..43f5a1285 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -54,6 +54,7 @@ use base qw(Exporter); bug_alias_to_id ValidateBugAlias ValidateBugID RemoveVotes CheckIfVotedConfirmed LogActivityEntry + is_open_state ); ##################################################################### @@ -203,7 +204,7 @@ sub initBug { } $self->{'isunconfirmed'} = ($self->{bug_status} eq 'UNCONFIRMED'); - $self->{'isopened'} = &::IsOpenedState($self->{bug_status}); + $self->{'isopened'} = is_open_state($self->{bug_status}); return $self; } @@ -758,6 +759,12 @@ sub EmitDependList { return $list_ref; } +# Tells you whether or not the argument is a valid "open" state. +sub is_open_state { + my ($state) = @_; + return (grep($_ eq $state, BUG_STATE_OPEN) ? 1 : 0); +} + sub ValidateTime { my ($time, $field) = @_; @@ -979,7 +986,7 @@ sub CountOpenDependencies { "FROM bugs, dependencies " . "WHERE blocked IN (" . (join "," , @bug_list) . ") " . "AND bug_id = dependson " . - "AND bug_status IN ('" . (join "','", &::OpenStates()) . "') " . + "AND bug_status IN ('" . (join "','", BUG_STATE_OPEN) . "') " . $dbh->sql_group_by('blocked')); $sth->execute(); diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index e20fb5f61..2b76a211a 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -37,6 +37,7 @@ use Bugzilla::User; use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Util; +use Bugzilla::Bug; use Date::Parse; use Date::Format; @@ -309,7 +310,7 @@ sub ProcessOneBug { $interestingchange = 0; } $thisdiff .= FormatTriple($fielddescription{$what}, $old, $new); - if ($what eq 'bug_status' && &::IsOpenedState($old) ne &::IsOpenedState($new)) { + if ($what eq 'bug_status' && is_open_state($old) ne is_open_state($new)) { $interestingchange = 1; } diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index afb621f78..0b612cbba 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -94,6 +94,8 @@ use base qw(Exporter); FIELD_TYPE_UNKNOWN FIELD_TYPE_FREETEXT + + BUG_STATE_OPEN ); @Bugzilla::Constants::EXPORT_OK = qw(contenttypes); @@ -256,4 +258,8 @@ use constant SENDMAIL_EXE => '/usr/lib/sendmail.exe'; use constant FIELD_TYPE_UNKNOWN => 0; use constant FIELD_TYPE_FREETEXT => 1; +# States that are considered to be "open" for bugs. +use constant BUG_STATE_OPEN => ('NEW', 'REOPENED', 'ASSIGNED', + 'UNCONFIRMED'); + 1; diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 9b6c5bca7..0914d69b0 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -41,6 +41,7 @@ use Bugzilla::Constants; use Bugzilla::Group; use Bugzilla::User; use Bugzilla::Field; +use Bugzilla::Bug; use Date::Format; use Date::Parse; @@ -186,11 +187,11 @@ sub init { $params->delete('bug_status'); } elsif ($bug_statuses[0] eq '__open__') { - $params->param('bug_status', map(&::IsOpenedState($_) ? $_ : undef, + $params->param('bug_status', map(is_open_state($_) ? $_ : undef, @::legal_bug_status)); } elsif ($bug_statuses[0] eq "__closed__") { - $params->param('bug_status', map(&::IsOpenedState($_) ? undef : $_, + $params->param('bug_status', map(is_open_state($_) ? undef : $_, @::legal_bug_status)); } } diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index 365e56469..4d9958c63 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -26,6 +26,8 @@ use strict; use Bugzilla; use Bugzilla::Config; use Bugzilla::Error; +use Bugzilla::Constants; +use Bugzilla::Bug; use base qw(Exporter); @Bugzilla::Search::Quicksearch::EXPORT = qw(quicksearch); @@ -153,12 +155,12 @@ sub quicksearch { my @words = splitString($searchstring); my $searchComments = $#words < Param('quicksearch_comment_cutoff'); - my @openStates = &::OpenStates(); + my @openStates = BUG_STATE_OPEN; my @closedStates; my (%states, %resolutions); foreach (@::legal_bug_status) { - push(@closedStates, $_) unless &::IsOpenedState($_); + push(@closedStates, $_) unless is_open_state($_); } foreach (@openStates) { $states{$_} = 1 } if ($words[0] eq 'ALL') { diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 2a83a4bea..edfc037c6 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -40,6 +40,7 @@ use Bugzilla::Util; use Bugzilla::User; use Bugzilla::Error; use MIME::Base64; +use Bugzilla::Bug; # for time2str - replace by TT Date plugin?? use Date::Format (); @@ -415,7 +416,7 @@ sub get_bug_link { $pre = "<i>"; $post = "</i>"; } - elsif (! &::IsOpenedState($bug_state)) { + elsif (!is_open_state($bug_state)) { $pre = '<span class="bz_closed">'; $title .= " $bug_res"; $post = '</span>'; diff --git a/buglist.cgi b/buglist.cgi index 7b66f14e8..4954ac607 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -1007,7 +1007,7 @@ $vars->{'buglist_joined'} = join(',', @bugidlist); $vars->{'columns'} = $columns; $vars->{'displaycolumns'} = \@displaycolumns; -my @openstates = OpenStates(); +my @openstates = BUG_STATE_OPEN; $vars->{'openstates'} = \@openstates; $vars->{'closedstates'} = ['CLOSED', 'VERIFIED', 'RESOLVED']; diff --git a/checksetup.pl b/checksetup.pl index 5d3a2e540..ab847674b 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -1449,6 +1449,9 @@ import Bugzilla::Util qw(bz_crypt trim html_quote is_7bit_clean); require Bugzilla::User; import Bugzilla::User qw(insert_new_user); +require Bugzilla::Bug; +import Bugzilla::Bug qw(is_open_state); + # globals.pl clears the PATH, but File::Find uses Cwd::cwd() instead of # Cwd::getcwd(), which we need to do because `pwd` isn't in the path - see # http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-09/msg00115.html @@ -3545,7 +3548,7 @@ if (!$series_exists) { $data{$fields[$i]}{$numbers[0]} = $numbers[$i + 1]; # Keep a total of the number of open bugs for this day - if (IsOpenedState($fields[$i])) { + if (is_open_state($fields[$i])) { $data{$open_name}{$numbers[0]} += $numbers[$i + 1]; } } @@ -4120,7 +4123,7 @@ if (@$broken_nonopen_series) { join("&", map { "bug_status=" . url_quote($_) } ('UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED')); my $open_bugs_query_base_new = - join("&", map { "bug_status=" . url_quote($_) } OpenStates()); + join("&", map { "bug_status=" . url_quote($_) } BUG_STATE_OPEN); my $sth_openbugs_series = $dbh->prepare("SELECT series_id FROM series WHERE query IN (?, ?)"); diff --git a/config.cgi b/config.cgi index c8c8ec887..371383e1c 100755 --- a/config.cgi +++ b/config.cgi @@ -33,6 +33,7 @@ use lib qw(.); require "globals.pl"; use Bugzilla; use Bugzilla::Constants; +use Bugzilla::Bug; # Suppress "used only once" warnings. use vars @@ -80,7 +81,7 @@ $vars->{'products'} = $user->get_selectable_products; my @open_status; my @closed_status; foreach my $status (@::legal_bug_status) { - IsOpenedState($status) ? push(@open_status, $status) + is_open_state($status) ? push(@open_status, $status) : push(@closed_status, $status); } $vars->{'open_status'} = \@open_status; diff --git a/editproducts.cgi b/editproducts.cgi index 25bad900d..68e6bd42a 100755 --- a/editproducts.cgi +++ b/editproducts.cgi @@ -294,7 +294,7 @@ if ($action eq 'new') { # For localisation reasons, we get the name of the "global" subcategory # and the title of the "open" query from the submitted form. - my @openedstatuses = OpenStates(); + my @openedstatuses = BUG_STATE_OPEN; my $query = join("&", map { "bug_status=" . url_quote($_) } @openedstatuses); push(@series, [$open_name, $query]); diff --git a/globals.pl b/globals.pl index 4bf1b3b34..be3df7d75 100644 --- a/globals.pl +++ b/globals.pl @@ -472,25 +472,6 @@ sub GroupIdToName { return $name; } -# Determines if the given bug_status string represents an "Opened" bug. This -# routine ought to be parameterizable somehow, as people tend to introduce -# new states into Bugzilla. - -sub IsOpenedState { - my ($state) = (@_); - if (grep($_ eq $state, OpenStates())) { - return 1; - } - return 0; -} - -# This sub will return an array containing any status that -# is considered an open bug. - -sub OpenStates { - return ('NEW', 'REOPENED', 'ASSIGNED', 'UNCONFIRMED'); -} - ############# Live code below here (that is, not subroutine defs) ############# use Bugzilla; diff --git a/importxml.pl b/importxml.pl index 3ad1ad4b6..7b96cb59e 100755 --- a/importxml.pl +++ b/importxml.pl @@ -896,7 +896,7 @@ sub process_bug { my $valid_status = check_field('bug_status', scalar $bug_fields{'bug_status'}, \@::legal_bug_status, ERR_LEVEL ); - my $is_open = IsOpenedState($bug_fields{'bug_status'}); + 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/process_bug.cgi b/process_bug.cgi index 0e5ec9427..c2605afc2 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -500,7 +500,7 @@ sub CheckCanChangeField { if ($field eq "canconfirm" || ($field eq "bug_status" && $oldvalue eq 'UNCONFIRMED' - && IsOpenedState($newvalue))) + && is_open_state($newvalue))) { $PrivilegesRequired = 3; return $UserInCanConfirmGroupSet; @@ -785,7 +785,7 @@ sub ChangeStatus { # confirmed or not $::query .= "bug_status = CASE WHEN everconfirmed = 1 THEN " . SqlQuote($str) . " ELSE 'UNCONFIRMED' END"; - } elsif (IsOpenedState($str)) { + } elsif (is_open_state($str)) { # Note that we cannot combine this with the above branch - here we # need to check if bugs.bug_status is open, (since we don't want to # reopen closed bugs when reassigning), while above the whole point @@ -811,7 +811,7 @@ sub ChangeStatus { # This also relies on the fact that confirming and accepting have # already called DoConfirm before this is called - my @open_state = map(SqlQuote($_), OpenStates()); + my @open_state = map(SqlQuote($_), BUG_STATE_OPEN); my $open_state = join(", ", @open_state); # If we are changing everconfirmed to 1, we have to take this change @@ -2040,7 +2040,7 @@ foreach my $id (@idlist) { } if ($col eq 'bug_status' - && IsOpenedState($old) ne IsOpenedState($new)) + && is_open_state($old) ne is_open_state($new)) { $check_dep_bugs = 1; } diff --git a/sanitycheck.cgi b/sanitycheck.cgi index 9a80efd24..7d2029bac 100755 --- a/sanitycheck.cgi +++ b/sanitycheck.cgi @@ -737,7 +737,7 @@ BugCheck("bugs LEFT JOIN duplicates ON bugs.bug_id = duplicates.dupe WHERE " . Status("Checking statuses/resolutions"); -my @open_states = map(SqlQuote($_), OpenStates()); +my @open_states = map(SqlQuote($_), BUG_STATE_OPEN); my $open_states = join(', ', @open_states); BugCheck("bugs WHERE bug_status IN ($open_states) AND resolution != ''", diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi index e97af975b..ed87b6d90 100755 --- a/showdependencygraph.cgi +++ b/showdependencygraph.cgi @@ -188,7 +188,7 @@ foreach my $k (keys(%seen)) { push(@params, "shape=box"); } - if (IsOpenedState($stat)) { + if (is_open_state($stat)) { push(@params, "color=green"); } diff --git a/showdependencytree.cgi b/showdependencytree.cgi index efc26a2b2..1a1e51d3a 100755 --- a/showdependencytree.cgi +++ b/showdependencytree.cgi @@ -166,7 +166,7 @@ sub GetBug { WHERE bugs.bug_id = ?", undef, $id); } - $bug->{'open'} = $bug->{'exists'} && IsOpenedState($bug->{'status'}); + $bug->{'open'} = $bug->{'exists'} && is_open_state($bug->{'status'}); $bug->{'dependencies'} = []; return $bug; @@ -186,7 +186,7 @@ sub show_user { push (@bugs, { id => $id, summary => $summary, count => $count, - opened => IsOpenedState($status) }); + opened => is_open_state($status) }); } # In case we didn't populate this earlier (i.e. an error, or |