summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Status.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2007-07-13 20:10:39 +0200
committerlpsolit%gmail.com <>2007-07-13 20:10:39 +0200
commitff222adc4a6cb0349f7642d61bb63d2ff970607c (patch)
treeba87c96d90582e7740991bc2c65dba56c92ee76c /Bugzilla/Status.pm
parent012d45ae9579b0f1690a2daed8212f38e9c9e26a (diff)
downloadbugzilla-ff222adc4a6cb0349f7642d61bb63d2ff970607c.tar.gz
bugzilla-ff222adc4a6cb0349f7642d61bb63d2ff970607c.tar.xz
Bug 385415: Bugs marked as duplicate or moved to another installation always go to the RESOLVED state, even if the workflow has RESOLVED excluded from it (or if this bug status has been removed or renamed). Some major problems related to the workflow when upgrading or installing 3.1 are also fixed here - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=mkanat
Diffstat (limited to 'Bugzilla/Status.pm')
-rw-r--r--Bugzilla/Status.pm55
1 files changed, 54 insertions, 1 deletions
diff --git a/Bugzilla/Status.pm b/Bugzilla/Status.pm
index e91f83871..cf8f98efa 100644
--- a/Bugzilla/Status.pm
+++ b/Bugzilla/Status.pm
@@ -54,15 +54,22 @@ sub is_open { return $_[0]->{'is_open'}; }
##### Methods ####
###############################
+sub closed_bug_statuses {
+ my @bug_statuses = Bugzilla::Status->get_all;
+ @bug_statuses = grep { !$_->is_open } @bug_statuses;
+ return @bug_statuses;
+}
+
sub can_change_to {
my $self = shift;
my $dbh = Bugzilla->dbh;
if (!ref($self) || !defined $self->{'can_change_to'}) {
- my ($cond, @args);
+ my ($cond, @args, $self_exists);
if (ref($self)) {
$cond = '= ?';
push(@args, $self->id);
+ $self_exists = 1;
}
else {
$cond = 'IS NULL';
@@ -78,12 +85,37 @@ sub can_change_to {
AND old_status $cond",
undef, @args);
+ # Allow the bug status to remain unchanged.
+ push(@$new_status_ids, $self->id) if $self_exists;
$self->{'can_change_to'} = Bugzilla::Status->new_from_list($new_status_ids);
}
return $self->{'can_change_to'};
}
+sub add_missing_bug_status_transitions {
+ my $bug_status = shift || Bugzilla->params->{'duplicate_or_move_bug_status'};
+ my $dbh = Bugzilla->dbh;
+ my $new_status = new Bugzilla::Status({name => $bug_status});
+ # Silently discard invalid bug statuses.
+ $new_status || return;
+
+ my $missing_statuses = $dbh->selectcol_arrayref('SELECT id
+ FROM bug_status
+ LEFT JOIN status_workflow
+ ON old_status = id
+ AND new_status = ?
+ WHERE old_status IS NULL',
+ undef, $new_status->id);
+
+ my $sth = $dbh->prepare('INSERT INTO status_workflow
+ (old_status, new_status) VALUES (?, ?)');
+
+ foreach my $old_status_id (@$missing_statuses) {
+ next if ($old_status_id == $new_status->id);
+ $sth->execute($old_status_id, $new_status->id);
+ }
+}
1;
@@ -100,6 +132,10 @@ 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();
+
+ Bugzilla::Status::add_missing_bug_status_transitions($bug_status);
+
=head1 DESCRIPTION
Status.pm represents a bug status object. It is an implementation
@@ -113,6 +149,15 @@ below.
=over
+=item C<closed_bug_statuses>
+
+ Description: Returns a list of C<Bugzilla::Status> objects which can have
+ a resolution associated with them ("closed" bug statuses).
+
+ Params: none.
+
+ Returns: A list of Bugzilla::Status objects.
+
=item C<can_change_to>
Description: Returns the list of active statuses a bug can be changed to
@@ -122,6 +167,14 @@ below.
Returns: A list of Bugzilla::Status objects.
+=item C<add_missing_bug_status_transitions>
+
+ Description: Insert all missing transitions to a given bug status.
+
+ Params: $bug_status - The value (name) of a bug status.
+
+ Returns: nothing.
+
=back
=cut