Remove is_open_state and BUG_STATE_OPEN

hinted-selects
Vitaliy Filippov 2014-07-23 19:47:56 +04:00
parent be8da34422
commit a10187577e
12 changed files with 45 additions and 56 deletions

View File

@ -3133,7 +3133,10 @@ sub status
{
my $self = shift;
return undef if !$self->{bug_status};
$self->{status} ||= new Bugzilla::Status($self->{bug_status});
if (!$self->{status})
{
($self->{status}) = grep { $_->id == $self->{bug_status} } Bugzilla::Status->get_all;
}
return $self->{status};
}
*bug_status_obj = *status;
@ -3975,7 +3978,9 @@ sub check_can_change_field
return 0;
}
# - change the status from one open state to another
if ($field eq 'bug_status' && is_open_state($oldvalue) && is_open_state($newvalue))
if ($field eq 'bug_status' &&
(grep { $_->is_open && $_->name eq $oldvalue } Bugzilla::Status->get_all) &&
(grep { $_->is_open && $_->name eq $newvalue } Bugzilla::Status->get_all))
{
$$PrivilegesRequired = 2;
return 0;

View File

@ -343,7 +343,8 @@ sub Send
$interestingchange = 0;
}
if ($dep_diff->{fieldname} eq 'bug_status' &&
is_open_state($dep_diff->{removed}) ne is_open_state($dep_diff->{added}))
scalar(grep { $_->is_open && $_->name eq $dep_diff->{removed} } Bugzilla::Status->get_all) !=
scalar(grep { $_->is_open && $_->name eq $dep_diff->{added} } Bugzilla::Status->get_all))
{
$interestingchange = 1;
}

View File

@ -734,7 +734,7 @@ sub _create_series
push(@series, [$resolution, "resolution=" . url_quote($resolution)]);
}
my @openedstatuses = BUG_STATE_OPEN;
my @openedstatuses = map { $_->name } grep { $_->is_open } @{ Bugzilla->get_field('bug_status')->legal_values };
my $query = join("&", map { "bug_status=" . url_quote($_) } @openedstatuses);
push(@series, [get_text('series_all_open'), $query]);

View File

@ -392,7 +392,7 @@ sub _handle_field_names
if (lc $_ eq 'open')
{
delete $st{$_};
$st{$_} = 1 for BUG_STATE_OPEN;
$st{$_->name} = 1 for grep { $_->is_open } @{ Bugzilla->get_field('bug_status')->legal_values };
}
}
if (%st && %res && $negate)

View File

@ -24,10 +24,8 @@ use Bugzilla::Error;
use base qw(Bugzilla::Field::Choice Exporter);
@Bugzilla::Status::EXPORT = qw(
BUG_STATE_OPEN
SPECIAL_STATUS_WORKFLOW_ACTIONS
is_open_state
closed_bug_statuses
);
@ -75,7 +73,6 @@ sub create
{
my $class = shift;
my $self = $class->SUPER::create(@_);
delete Bugzilla->request_cache->{status_bug_state_open};
add_missing_bug_status_transitions();
return $self;
}
@ -89,7 +86,6 @@ sub remove_from_db
$self->SUPER::remove_from_db();
$dbh->do('DELETE FROM status_workflow WHERE old_status = ? OR new_status = ?', undef, $id, $id);
$dbh->bz_commit_transaction();
delete Bugzilla->request_cache->{status_bug_state_open};
}
###############################
@ -126,22 +122,6 @@ sub _check_value
##### Methods ####
###############################
sub BUG_STATE_OPEN
{
my $dbh = Bugzilla->dbh;
my $cache = Bugzilla->request_cache;
$cache->{status_bug_state_open} ||= $dbh->selectcol_arrayref('SELECT value FROM bug_status WHERE is_open = 1');
return @{ $cache->{status_bug_state_open} };
}
# Tells you whether or not the argument is a valid "open" state.
# FIXME Remove is_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;

View File

@ -1100,7 +1100,7 @@ $vars->{buglist_joined} = join(',', @bugidlist);
$vars->{columns} = $columns;
$vars->{displaycolumns} = \@displaycolumns;
$vars->{openstates} = [BUG_STATE_OPEN];
$vars->{openstates} = [ map { $_->name } grep { $_->is_open } Bugzilla::Status->get_all ];
# used by list.ics.tmpl
$vars->{assignedstates} = [ map { $_->name } grep { $_->is_active && $_->is_assigned } Bugzilla::Status->get_all ];
$vars->{closedstates} = [ map { $_->name } closed_bug_statuses() ];

View File

@ -92,13 +92,12 @@ else {
$vars->{'show_flags'} = 1;
}
# Create separate lists of open versus resolved statuses. This should really
# be made part of the configuration.
# Create separate lists of open versus resolved statuses.
my @open_status;
my @closed_status;
foreach my $status (@{$vars->{'status'}}) {
is_open_state($status) ? push(@open_status, $status)
: push(@closed_status, $status);
foreach my $status (@{ Bugzilla->get_field('bug_status')->legal_values })
{
$status->is_open ? push(@open_status, $status->name) : push(@closed_stat, $status->name);
}
$vars->{'open_status'} = \@open_status;
$vars->{'closed_status'} = \@closed_status;

View File

@ -900,7 +900,7 @@ sub process_bug {
my $valid_status = check_field('bug_status',
scalar $bug_fields{'bug_status'},
undef, ERR_LEVEL );
my $is_open = is_open_state($bug_fields{'bug_status'});
my $is_open = grep { $_->is_open && $_->name eq $bug_fields{'bug_status'} } Bugzilla::Status->get_all;
my $status = $bug_fields{'bug_status'} || undef;
my $resolution = $bug_fields{'resolution'} || undef;

View File

@ -640,6 +640,7 @@ foreach my $bug (@bug_objects)
my $mail_count = @{Bugzilla->get_mail_result()};
my $timestamp = $dbh->selectrow_array(q{SELECT LOCALTIMESTAMP(0)});
my $old_status = $bug->{_old_self}->bug_status_obj;
my $changes = $bug->update($timestamp);
if ($bug->{failed_checkers} && @{$bug->{failed_checkers}} &&
@ -655,18 +656,18 @@ foreach my $bug (@bug_objects)
my %notify_deps;
if ($changes->{bug_status})
{
my ($old_status, $new_status) = @{ $changes->{bug_status} };
my $new_status = $bug->bug_status_obj;
# If this bug has changed from opened to closed or vice-versa,
# then all of the bugs we block need to be notified.
if (is_open_state($old_status) ne is_open_state($new_status))
if ($old_status->is_open != $new_status->is_open)
{
$notify_deps{$_} = 1 foreach @{$bug->blocked};
}
# We may have zeroed the remaining time, if we moved into a closed
# status, so we should inform the user about that.
if (!is_open_state($new_status) && $changes->{remaining_time} &&
if (!$new_status->is_open && $changes->{remaining_time} &&
!$changes->{remaining_time}->[1] &&
Bugzilla->user->in_group(Bugzilla->params->{timetrackinggroup}))
{

View File

@ -72,7 +72,7 @@ if (!$product_name) {
|| ThrowCodeError('chart_dir_nonexistent',
{dir => $dir, graph_dir => $graph_dir});
my %default_sel = map { $_ => 1 } BUG_STATE_OPEN;
my %default_sel = map { $_ => 1 } grep { $_->is_open } Bugzilla::Status->get_all;
my @datasets;
my @data = get_data($dir);

View File

@ -221,12 +221,11 @@ if ($cgi->param('repair_creation_date')) {
if ($cgi->param('repair_everconfirmed')) {
Status('everconfirmed_start');
# FIXME Remove bug_status==UNCONFIRMED hardcode
my @confirmed_open_states = grep {$_ ne 'UNCONFIRMED'} BUG_STATE_OPEN;
my $confirmed_open_states = join(', ', map {$dbh->quote($_)} @confirmed_open_states);
my $unconfirmed_states = join(', ', map { $dbh->quote($_->name) } grep { !$_->is_confirmed } Bugzilla::Status->get_all);
my $confirmed_states = join(', ', map { $dbh->quote($_->name) } grep { $_->is_confirmed } Bugzilla::Status->get_all);
$dbh->do("UPDATE bugs SET everconfirmed = 0 WHERE bug_status = 'UNCONFIRMED'");
$dbh->do("UPDATE bugs SET everconfirmed = 1 WHERE bug_status IN ($confirmed_open_states)");
$dbh->do("UPDATE bugs SET everconfirmed = 0 WHERE bug_status IN ($unconfirmed_states)");
$dbh->do("UPDATE bugs SET everconfirmed = 1 WHERE bug_status IN ($confirmed_states)");
Status('everconfirmed_end');
}
@ -829,7 +828,7 @@ BugCheck("bugs LEFT JOIN duplicates ON bugs.bug_id = duplicates.dupe WHERE " .
Status('bug_check_status_res');
my @open_states = map($dbh->quote($_), BUG_STATE_OPEN);
my @open_states = map($dbh->quote($_->name), grep { $_->is_open } Bugzilla::Status->get_all);
my $open_states = join(', ', @open_states);
BugCheck("bugs WHERE bug_status IN ($open_states) AND resolution != ''",
@ -839,13 +838,14 @@ BugCheck("bugs WHERE bug_status NOT IN ($open_states) AND resolution = ''",
Status('bug_check_status_everconfirmed');
BugCheck("bugs WHERE bug_status = 'UNCONFIRMED' AND everconfirmed = 1",
my $unconfirmed_states = join(', ', map { $dbh->quote($_->name) } grep { !$_->is_confirmed } Bugzilla::Status->get_all);
BugCheck("bugs WHERE bug_status IN ($unconfirmed_states) AND everconfirmed = 1",
'bug_check_status_everconfirmed_error_text', 'repair_everconfirmed');
my @confirmed_open_states = grep {$_ ne 'UNCONFIRMED'} BUG_STATE_OPEN;
my $confirmed_open_states = join(', ', map {$dbh->quote($_)} @confirmed_open_states);
my $confirmed_states = join(', ', map { $dbh->quote($_->name) } grep { $_->is_confirmed } Bugzilla::Status->get_all);
BugCheck("bugs WHERE bug_status IN ($confirmed_open_states) AND everconfirmed = 0",
BugCheck("bugs WHERE bug_status IN ($confirmed_states) AND everconfirmed = 0",
'bug_check_status_everconfirmed_error_text2', 'repair_everconfirmed');
Status('bug_check_votes_everconfirmed');

View File

@ -300,9 +300,12 @@ sub GetEdges
if ($display eq 'web' || $display eq 'openweb')
{
my $openweb = $display eq 'openweb' ? 1 : 0;
my $sth = $dbh->prepare("SELECT blocked, dependson, bs.bug_status blocked_status, ds.bug_status dependson_status
FROM dependencies, bugs bs, bugs ds
WHERE (blocked=? OR dependson=?) AND bs.bug_id=blocked AND ds.bug_id=dependson");
my $sth = $dbh->prepare(
"SELECT blocked, dependson, bss.is_open blocked_open, dss.is_open dependson_open".
" FROM dependencies, bugs bs, bugs ds, bug_status bss, bug_status dss".
" WHERE (blocked=? OR dependson=?) AND bs.bug_id=blocked AND ds.bug_id=dependson".
" AND bss.id=bs.bug_status AND dss.id=ds.bug_status"
);
foreach my $id (@stack)
{
my $dependencies = $dbh->selectall_arrayref($sth, undef, ($id, $id));
@ -311,12 +314,12 @@ sub GetEdges
my ($blocked, $dependson, $bs, $ds) = @$dependency;
if ($blocked != $id && !exists $seen->{$blocked})
{
next if $openweb && !is_open_state($bs); # skip AddLink also
next if $openweb && !$bs; # skip AddLink also
push @stack, $blocked;
}
if ($dependson != $id && !exists $seen->{$dependson})
{
next if $openweb && !is_open_state($ds); # skip AddLink also
next if $openweb && !$ds; # skip AddLink also
push @stack, $dependson;
}
AddLink($blocked, $dependson, $seen, $edges);
@ -364,6 +367,7 @@ sub GetNodes
"SELECT
t1.bug_id,
bs.value bug_status,
bs.is_open is_open,
res.value resolution,
t1.short_desc,
t1.estimated_time,
@ -387,7 +391,6 @@ GROUP BY t1.bug_id", {Slice=>{}}, keys %$seen) || {};
{
# Resolution and summary are shown only if user can see the bug
$row->{resolution} = $row->{short_desc} = '' unless Bugzilla->user->can_see_bug($row->{bug_id});
$row->{bug_status} ||= 'NEW';
$row->{short_desc_uncut} = $row->{short_desc};
if (length $row->{short_desc} > 32)
{
@ -397,8 +400,8 @@ GROUP BY t1.bug_id", {Slice=>{}}, keys %$seen) || {};
$vars->{short_desc} = $row->{short_desc} if $row->{bug_id} eq Bugzilla->cgi->param('id');
Encode::_utf8_off($row->{$_}) for keys %$row;
my $bgnodecolor = GetColorByState($row->{bug_status}, 1);
my $nodecolor = GetColorByState($row->{bug_status});
my $bgnodecolor = GetColorByState($row->{bug_status}, $row->{is_open}, 1);
my $nodecolor = GetColorByState($row->{bug_status}, $row->{is_open});
my $assigneecolor = "white";
$assigneecolor = "red1" if $row->{bug_severity} eq "blocker";
@ -519,7 +522,7 @@ sub CleanupOldDots
sub GetColorByState
{
my ($state, $base) = (@_);
my ($state, $open, $base) = (@_);
$base = $base ? 0 : 0x40;
# FIXME Remove bug_status hardcode
my %colorbystate = (
@ -536,6 +539,6 @@ sub GetColorByState
my $color = sprintf("\"#%02x%02x%02x\"", map { int(ord($_)/0xff*(0xff-$base)) }
split //, pack 'H*',
$colorbystate{$state} ||
$colorbystate{is_open_state($state) ? 'opened' : 'closed'});
$colorbystate{$open ? 'opened' : 'closed'});
return $color;
}