Closed
Bug 512648
Opened 15 years ago
Closed 13 years ago
Bugzilla::Bug should centrally control available statuses in enter_bug.cgi
Categories
(Bugzilla :: Creating/Changing Bugs, enhancement)
Tracking
()
RESOLVED
FIXED
Bugzilla 4.4
People
(Reporter: mkanat, Assigned: rowebb)
References
Details
Attachments
(1 file, 5 obsolete files)
5.62 KB,
patch
|
mkanat
:
review+
|
Details | Diff | Splinter Review |
Right now there's pretty much duplicate code in enter_bug.cgi and Bugzilla::Bug::_check_bug_status to determine which statuses are valid for this user when filing a bug. It should be centralized in Bugzilla::Bug so that people can make changes to it in just one place and have it be effective everywhere.
Comment 1•15 years ago
|
||
We no longer accept new features for Bugzilla 3.6. Retargetting to 3.8.
Target Milestone: Bugzilla 3.6 → Bugzilla 3.8
Reporter | ||
Updated•14 years ago
|
Target Milestone: Bugzilla 4.0 → Bugzilla 5.0
Assignee | ||
Updated•13 years ago
|
Assignee: create-and-change → rowebb
Assignee | ||
Comment 2•13 years ago
|
||
This is a first go at refactoring the default bug status code. Unfortunately I had to make some choices that I thought were rather hacky. Because enter_bug requires both a list of available new bug statuses in addition to a default bug status, I had to make two methods to get these.
Attachment #560635 -
Flags: review?(mkanat)
Assignee | ||
Updated•13 years ago
|
Status: NEW → ASSIGNED
Reporter | ||
Comment 3•13 years ago
|
||
Comment on attachment 560635 [details] [diff] [review] Proposed refactoring patch v1 Review of attachment 560635 [details] [diff] [review]: ----------------------------------------------------------------- Overall, I like this approach. I don't feel too much like it's a hack, at all, actually. :-) ::: Bugzilla/Bug.pm @@ +3222,5 @@ > return $self->{classification}; > } > > +sub default_bug_status { > + my ($class) = shift; You don't need the ( ) around $class there. @@ +3223,5 @@ > } > > +sub default_bug_status { > + my ($class) = shift; > + my @statuses = @_; Hmm, could you just call new_bug_statuses inside of this method? I think that would be cleaner. @@ +3226,5 @@ > + my ($class) = shift; > + my @statuses = @_; > + > + my $status; > + if (scalar @statuses == 1) { parens: scalar(@statuses) == 1 (for clarity) @@ +3354,5 @@ > return \@comments; > } > > +sub new_bug_statuses { > + my ($class, $product, $user) = @_; Instead of passing $user, you should use Bugzilla->user. @@ +3361,5 @@ > + my @statuses = @{ Bugzilla::Bug->statuses_available($product) }; > + > + # If the user has no privs... > + unless ($user->in_group('editbugs', $product->id) || > + $user->in_group('canconfirm', $product->id)) { The open-curly-brace gets aligned with the "u" in "unless" for this. @@ +3486,5 @@ > + > + # If this bug has an inactive status set, it should still be in the list. > + if (!grep($_->name eq $invocant->status->name, @available)) { > + unshift(@available, $invocant->status); > + } Could you break the above bits out into a separate helper function, just for readability's sake?
Attachment #560635 -
Flags: review?(mkanat) → review-
Assignee | ||
Comment 4•13 years ago
|
||
Made the requested changes.
Attachment #560635 -
Attachment is obsolete: true
Attachment #561313 -
Flags: review?(mkanat)
Comment 5•13 years ago
|
||
Comment on attachment 561313 [details] [diff] [review] Proposed refactoring patch v2 >=== modified file 'Bugzilla/Bug.pm' >+ unless ($user->in_group('editbugs', $product->id) || >+ $user->in_group('canconfirm', $product->id)) Please put || at the beginning of the next line. >+ $invocant->{'statuses_available'} = $available; >+ return $invocant->{'statuses_available'}; Nit: you could simply write: return $available. >+sub _refine_avialable_statuses { Typo in the name: avialable -> available >+ my $invocant = shift; No reason to rename $self to $invocant. This method is only called for existing bugs. Otherwise looks good.
Attachment #561313 -
Flags: review?(mkanat) → review-
Assignee | ||
Comment 6•13 years ago
|
||
Requested changes have been made.
Attachment #561313 -
Attachment is obsolete: true
Attachment #561338 -
Flags: review?(mkanat)
Reporter | ||
Comment 7•13 years ago
|
||
Comment on attachment 561338 [details] [diff] [review] Proposed refactoring patch v3 Review of attachment 561338 [details] [diff] [review]: ----------------------------------------------------------------- ::: Bugzilla/Bug.pm @@ +1283,4 @@ > else { > $product = $params->{product}; > $comment = $params->{comment}; > + @valid_statuses = @{Bugzilla::Bug->statuses_available($product)}; Nit: Space after { and before }. @@ +3339,4 @@ > return \@comments; > } > > +sub new_bug_status { Ah, I'd rather have this called default_bug_status, that makes more sense. @@ +3340,5 @@ > } > > +sub new_bug_status { > + my $class = shift; > + my @statuses = @_; What about using new_bug_statuses here instead of passing in @statuses?
Attachment #561338 -
Flags: review?(mkanat) → review-
Assignee | ||
Comment 8•13 years ago
|
||
Attachment #561338 -
Attachment is obsolete: true
Attachment #561344 -
Flags: review?(mkanat)
Assignee | ||
Comment 9•13 years ago
|
||
Attachment #561344 -
Attachment is obsolete: true
Attachment #561347 -
Flags: review?(mkanat)
Attachment #561344 -
Flags: review?(mkanat)
Assignee | ||
Comment 10•13 years ago
|
||
Attachment #561347 -
Attachment is obsolete: true
Attachment #561348 -
Flags: review?(mkanat)
Attachment #561347 -
Flags: review?(mkanat)
Reporter | ||
Comment 11•13 years ago
|
||
Comment on attachment 561348 [details] [diff] [review] Proposed refactoring patch v4 Review of attachment 561348 [details] [diff] [review]: ----------------------------------------------------------------- Looks awesome. :-) Thank you! ::: Bugzilla/Bug.pm @@ +3466,5 @@ > + if (ref $invocant) { > + return [] if $invocant->{'error'}; > + > + return $invocant->{'statuses_available'} > + if defined $invocant->{'statuses_available'}; Nit: Four spaces for the indent, there.
Attachment #561348 -
Flags: review?(mkanat) → review+
Reporter | ||
Comment 12•13 years ago
|
||
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/ modified enter_bug.cgi modified Bugzilla/Bug.pm Committed revision 7968.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Flags: approval+
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•