summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2007-06-14 23:25:41 +0200
committerlpsolit%gmail.com <>2007-06-14 23:25:41 +0200
commit80c5b6fadda4e77e5a48cd50e55cbe710a31ca83 (patch)
tree3c0e225a4810e080b2bc7f8ff3dc10485b92b267 /Bugzilla
parent836b976e508db4efa1775d0beb0704cb56f28695 (diff)
downloadbugzilla-80c5b6fadda4e77e5a48cd50e55cbe710a31ca83.tar.gz
bugzilla-80c5b6fadda4e77e5a48cd50e55cbe710a31ca83.tar.xz
Bug 344964: enter_bug.cgi should look at the custom status workflow to get the valid initial bug statuses - Patch by Frédéric Buclin <LpSolit@gmail.com> r=gerv a=justdave
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm44
-rw-r--r--Bugzilla/Status.pm19
2 files changed, 33 insertions, 30 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index ce4423a27..5ca806092 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -170,14 +170,6 @@ use constant MAX_LINE_LENGTH => 254;
# Used in ValidateComment(). Gives the max length allowed for a comment.
use constant MAX_COMMENT_LENGTH => 65535;
-# The statuses that are valid on enter_bug.cgi and post_bug.cgi.
-# The order is important--see _check_bug_status
-use constant VALID_ENTRY_STATUS => qw(
- UNCONFIRMED
- NEW
- ASSIGNED
-);
-
use constant SPECIAL_STATUS_WORKFLOW_ACTIONS => qw(
none
duplicate
@@ -593,38 +585,38 @@ sub _check_bug_status {
my ($invocant, $status, $product) = @_;
my $user = Bugzilla->user;
- my %valid_statuses;
+ my @valid_statuses;
if (ref $invocant) {
$invocant->{'prod_obj'} ||=
new Bugzilla::Product({name => $invocant->product});
$product = $invocant->{'prod_obj'};
- my $field = new Bugzilla::Field({ name => 'bug_status' });
- %valid_statuses = map { $_ => 1 } @{$field->legal_values};
+ @valid_statuses = map { $_->name } @{$invocant->status->can_change_to};
}
else {
- %valid_statuses = map { $_ => 1 } VALID_ENTRY_STATUS;
+ @valid_statuses = map { $_->name } @{Bugzilla::Status->can_change_to()};
+ }
+ if (!$product->votes_to_confirm) {
+ # UNCONFIRMED becomes an invalid status if votes_to_confirm is 0,
+ # even if you are in editbugs.
+ @valid_statuses = grep {$_ ne 'UNCONFIRMED'} @valid_statuses;
+ }
+
+ if (!ref($invocant)) {
if ($user->in_group('editbugs', $product->id)
|| $user->in_group('canconfirm', $product->id)) {
- # Default to NEW if the user with privs hasn't selected another
- # status.
- $status ||= 'NEW';
- }
- elsif (!$product->votes_to_confirm) {
- # Without privs, products that don't support UNCONFIRMED default
- # to NEW.
- $status = 'NEW';
+ # If the user with privs hasn't selected another status,
+ # select the first one of the list.
+ $status ||= $valid_statuses[0];
}
else {
- $status = 'UNCONFIRMED';
+ # A user with no privs cannot choose the initial status.
+ $status = $valid_statuses[0];
}
}
- # UNCONFIRMED becomes an invalid status if votes_to_confirm is 0,
- # even if you are in editbugs.
- delete $valid_statuses{'UNCONFIRMED'} if !$product->votes_to_confirm;
-
- check_field('bug_status', $status, [keys %valid_statuses]);
+ # This check already takes the workflow into account.
+ check_field('bug_status', $status, \@valid_statuses);
return $status if ref $invocant;
return ($status, $status eq 'UNCONFIRMED' ? 0 : 1);
diff --git a/Bugzilla/Status.pm b/Bugzilla/Status.pm
index e83fd3533..e91f83871 100644
--- a/Bugzilla/Status.pm
+++ b/Bugzilla/Status.pm
@@ -58,14 +58,25 @@ sub can_change_to {
my $self = shift;
my $dbh = Bugzilla->dbh;
- if (!defined $self->{'can_change_to'}) {
- my $new_status_ids = $dbh->selectcol_arrayref('SELECT new_status
+ if (!ref($self) || !defined $self->{'can_change_to'}) {
+ my ($cond, @args);
+ if (ref($self)) {
+ $cond = '= ?';
+ push(@args, $self->id);
+ }
+ else {
+ $cond = 'IS NULL';
+ # Let's do it so that the code below works in all cases.
+ $self = {};
+ }
+
+ my $new_status_ids = $dbh->selectcol_arrayref("SELECT new_status
FROM status_workflow
INNER JOIN bug_status
ON id = new_status
WHERE isactive = 1
- AND old_status = ?',
- undef, $self->id);
+ AND old_status $cond",
+ undef, @args);
$self->{'can_change_to'} = Bugzilla::Status->new_from_list($new_status_ids);
}