summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2007-07-28 07:54:36 +0200
committerlpsolit%gmail.com <>2007-07-28 07:54:36 +0200
commit737535fcbcfd91d7c15eab2f43386333af113797 (patch)
tree11f720ceb06a1774840735eb9dc602b47252b97a /Bugzilla
parent0885b2b60ea61f2b3ca8d1f61049412f340b6c6d (diff)
downloadbugzilla-737535fcbcfd91d7c15eab2f43386333af113797.tar.gz
bugzilla-737535fcbcfd91d7c15eab2f43386333af113797.tar.xz
Bug 389835: Various issues when changing several bugs at once - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=mkanat
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm27
-rw-r--r--Bugzilla/Status.pm37
2 files changed, 41 insertions, 23 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index de1884b7f..4793c87da 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1899,30 +1899,13 @@ sub bug_alias_to_id {
# Workflow Control routines
#####################################################################
-# Make sure that the new status is valid for ALL bugs.
+# Make sure that the new status is allowed by the status workflow.
sub check_status_transition {
- my ($self, $new_status, $bug_ids) = @_;
- my $dbh = Bugzilla->dbh;
+ my ($self, $new_status) = @_;
- check_field('bug_status', $new_status);
- trick_taint($new_status);
-
- my $illegal_statuses =
- $dbh->selectcol_arrayref('SELECT DISTINCT bug_status.value
- FROM bug_status
- INNER JOIN bugs
- ON bugs.bug_status = bug_status.value
- WHERE bug_id IN (' . join (',', @$bug_ids). ')
- AND bug_status.id NOT IN (SELECT old_status
- FROM status_workflow
- INNER JOIN bug_status b_s
- ON b_s.id = status_workflow.new_status
- WHERE b_s.value = ?)',
- undef, $new_status);
-
- if (scalar(@$illegal_statuses)) {
- ThrowUserError('illegal_bug_status_transition', {old => $illegal_statuses,
- new => $new_status})
+ if (!grep { $_->name eq $self->bug_status } @{$new_status->can_change_from}) {
+ ThrowUserError('illegal_bug_status_transition', {old => $self->bug_status,
+ new => $new_status->name})
}
}
diff --git a/Bugzilla/Status.pm b/Bugzilla/Status.pm
index cf8f98efa..9af0f043c 100644
--- a/Bugzilla/Status.pm
+++ b/Bugzilla/Status.pm
@@ -93,6 +93,28 @@ sub can_change_to {
return $self->{'can_change_to'};
}
+sub can_change_from {
+ my $self = shift;
+ my $dbh = Bugzilla->dbh;
+
+ if (!defined $self->{'can_change_from'}) {
+ my $old_status_ids = $dbh->selectcol_arrayref('SELECT old_status
+ FROM status_workflow
+ INNER JOIN bug_status
+ ON id = old_status
+ WHERE isactive = 1
+ AND new_status = ?
+ AND old_status IS NOT NULL',
+ undef, $self->id);
+
+ # Allow the bug status to remain unchanged.
+ push(@$old_status_ids, $self->id);
+ $self->{'can_change_from'} = Bugzilla::Status->new_from_list($old_status_ids);
+ }
+
+ return $self->{'can_change_from'};
+}
+
sub add_missing_bug_status_transitions {
my $bug_status = shift || Bugzilla->params->{'duplicate_or_move_bug_status'};
my $dbh = Bugzilla->dbh;
@@ -161,7 +183,20 @@ below.
=item C<can_change_to>
Description: Returns the list of active statuses a bug can be changed to
- given the current bug status.
+ given the current bug status. If this method is called as a
+ class method, then it returns all bug statuses available on
+ bug creation.
+
+ Params: none.
+
+ Returns: A list of Bugzilla::Status objects.
+
+=item C<can_change_from>
+
+ Description: Returns the list of active statuses a bug can be changed from
+ given the new bug status. If the bug status is available on
+ bug creation, this method doesn't return this information.
+ You have to call C<can_change_to> instead.
Params: none.