Commit 1b8e4cad authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 387672: Move BUG_STATE_OPEN and is_open_state() into Status.pm - Patch by…

Bug 387672: Move BUG_STATE_OPEN and is_open_state() into Status.pm - Patch by Fré©ric Buclin <LpSolit@gmail.com> r/a=mkanat
parent 73553366
......@@ -53,7 +53,6 @@ use base qw(Bugzilla::Object Exporter);
bug_alias_to_id ValidateBugID
RemoveVotes CheckIfVotedConfirmed
LogActivityEntry
BUG_STATE_OPEN is_open_state
editable_bug_fields
SPECIAL_STATUS_WORKFLOW_ACTIONS
);
......@@ -223,12 +222,6 @@ use constant SPECIAL_STATUS_WORKFLOW_ACTIONS => qw(
clearresolution
);
sub BUG_STATE_OPEN {
# XXX - We should cache this list.
my $dbh = Bugzilla->dbh;
return @{$dbh->selectcol_arrayref('SELECT value FROM bug_status WHERE is_open = 1')};
}
#####################################################################
sub new {
......@@ -2428,12 +2421,6 @@ 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) = @_;
......
......@@ -40,6 +40,7 @@ use Bugzilla::Bug;
use Bugzilla::Classification;
use Bugzilla::Product;
use Bugzilla::Component;
use Bugzilla::Status;
use Bugzilla::Mailer;
use Date::Parse;
......@@ -308,7 +309,7 @@ sub Send {
}
$thisdiff .= FormatTriple($fielddescription{$what}, $old, $new);
if ($what eq 'bug_status'
&& Bugzilla::Bug::is_open_state($old) ne Bugzilla::Bug::is_open_state($new))
&& is_open_state($old) ne is_open_state($new))
{
$interestingchange = 1;
}
......
......@@ -48,7 +48,7 @@ sub get_param_list {
# and bug_status.is_open is not yet defined (hence the eval), so we use
# the bug statuses above as they are still hardcoded.
eval {
my @current_closed_states = map {$_->name} Bugzilla::Status::closed_bug_statuses();
my @current_closed_states = map {$_->name} closed_bug_statuses();
# If no closed state was found, use the default list above.
@closed_bug_statuses = @current_closed_states if scalar(@current_closed_states);
};
......
......@@ -170,7 +170,7 @@ sub check_opsys {
sub check_bug_status {
my $bug_status = shift;
my @closed_bug_statuses = map {$_->name} Bugzilla::Status::closed_bug_statuses();
my @closed_bug_statuses = map {$_->name} closed_bug_statuses();
if (lsearch(\@closed_bug_statuses, $bug_status) < 0) {
return "Must be a valid closed status: one of " . join(', ', @closed_bug_statuses);
}
......
......@@ -40,7 +40,7 @@ use Bugzilla::Constants;
use Bugzilla::Group;
use Bugzilla::User;
use Bugzilla::Field;
use Bugzilla::Bug;
use Bugzilla::Status;
use Bugzilla::Keyword;
use Date::Format;
......
......@@ -26,7 +26,7 @@ use strict;
use Bugzilla::Error;
use Bugzilla::Constants;
use Bugzilla::Keyword;
use Bugzilla::Bug;
use Bugzilla::Status;
use Bugzilla::Field;
use Bugzilla::Util;
......
......@@ -22,7 +22,8 @@ use strict;
package Bugzilla::Status;
use base qw(Bugzilla::Object);
use base qw(Bugzilla::Object Exporter);
@Bugzilla::Status::EXPORT = qw(BUG_STATE_OPEN is_open_state closed_bug_statuses);
################################
##### Initialization #####
......@@ -54,6 +55,18 @@ sub is_open { return $_[0]->{'is_open'}; }
##### Methods ####
###############################
sub BUG_STATE_OPEN {
# XXX - We should cache this list.
my $dbh = Bugzilla->dbh;
return @{$dbh->selectcol_arrayref('SELECT value FROM bug_status WHERE is_open = 1')};
}
# 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 closed_bug_statuses {
my @bug_statuses = Bugzilla::Status->get_all;
@bug_statuses = grep { !$_->is_open } @bug_statuses;
......@@ -154,7 +167,7 @@ Bugzilla::Status - Bug status class.
my $bug_status = new Bugzilla::Status({name => 'ASSIGNED'});
my $bug_status = new Bugzilla::Status(4);
my @closed_bug_statuses = Bugzilla::Status::closed_bug_statuses();
my @closed_bug_statuses = closed_bug_statuses();
Bugzilla::Status::add_missing_bug_status_transitions($bug_status);
......
......@@ -40,9 +40,9 @@ use Bugzilla::Install::Util qw(template_include_path);
use Bugzilla::Util;
use Bugzilla::User;
use Bugzilla::Error;
use MIME::Base64;
use Bugzilla::Bug;
use Bugzilla::Status;
use MIME::Base64;
# for time2str - replace by TT Date plugin??
use Date::Format ();
use File::Find;
......
......@@ -46,6 +46,7 @@ use Bugzilla::Bug;
use Bugzilla::Product;
use Bugzilla::Keyword;
use Bugzilla::Field;
use Bugzilla::Status;
use Date::Parse;
......@@ -1111,7 +1112,7 @@ $vars->{'columns'} = $columns;
$vars->{'displaycolumns'} = \@displaycolumns;
$vars->{'openstates'} = [BUG_STATE_OPEN];
$vars->{'closedstates'} = [map {$_->name} Bugzilla::Status::closed_bug_statuses()];
$vars->{'closedstates'} = [map {$_->name} closed_bug_statuses()];
# The list of query fields in URL query string format, used when creating
# URLs to the same query results page with different parameters (such as
......
......@@ -34,7 +34,7 @@ use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Keyword;
use Bugzilla::Bug;
use Bugzilla::Status;
use Bugzilla::Field;
my $user = Bugzilla->login(LOGIN_OPTIONAL);
......
......@@ -48,6 +48,7 @@ use Bugzilla::Group;
use Bugzilla::User;
use Bugzilla::Field;
use Bugzilla::Token;
use Bugzilla::Status;
#
# Preliminary checks:
......
......@@ -58,6 +58,7 @@ use Bugzilla::Product;
use Bugzilla::Component;
use Bugzilla::Keyword;
use Bugzilla::Flag;
use Bugzilla::Status;
use Storable qw(dclone);
......
......@@ -43,7 +43,7 @@ use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Bug;
use Bugzilla::Status;
eval "use GD";
$@ && ThrowCodeError("gd_not_installed");
......
......@@ -32,7 +32,7 @@ use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Bug;
use Bugzilla::Status;
###########################################################################
# General subs
......
......@@ -32,6 +32,7 @@ use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Bug;
use Bugzilla::Status;
Bugzilla->login();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment