Closed Bug 388149 Opened 19 years ago Closed 19 years ago

Move updating of time-tracking fields into Bugzilla::Bug

Categories

(Bugzilla :: Creating/Changing Bugs, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 3.2

People

(Reporter: mkanat, Assigned: mkanat)

References

Details

Attachments

(1 file, 5 obsolete files)

These ones should be quite easy (estimated_time, remaining_time, and deadline).
Attached patch v1 (obsolete) — — Splinter Review
Okay, here it is. Just so you know, NUMERIC_COLUMNS exists because update() was returning estimated_time and remaining_time in %changes, always. (Because '1.00' does not "eq" '1', and the value in the DB was always something like '1.00'.)
Attachment #272311 - Flags: review?(LpSolit)
Attachment #272311 - Attachment is patch: true
Attachment #272311 - Attachment mime type: text/x-patch → text/plain
Comment on attachment 272311 [details] [diff] [review] v1 Your patch looks good, but there is now some duplicated code which can go away IMO: http://lxr.mozilla.org/mozilla/source/webtools/bugzilla/process_bug.cgi#147 Also, what do you do with _remove_remaining_time() at http://lxr.mozilla.org/mozilla/source/webtools/bugzilla/process_bug.cgi#553 ?
Attachment #272311 - Flags: review?(LpSolit) → review-
Attached patch v2 (obsolete) — — Splinter Review
Okay, I removed that code. _remove_remaining_time will still work, because there's still an UPDATE statement in process_bug that happens after bug->update. _remove_remaining_time will have to be moved after we finish making set_status and set_resolution.
Attachment #272311 - Attachment is obsolete: true
Attachment #272427 - Flags: review?(LpSolit)
Comment on attachment 272427 [details] [diff] [review] v2 For some reason, the remaining time is no longer reset to 0 when closing a single bug. This is also broken when editing several bugs at once, but in this last case it was already broken without your patch applied. It seems the reason is bug 320058: process_bug.cgi: Argument "--do_not_change--" isn't numeric in numeric gt (>) at /var/www/html/bugzilla/process_bug.cgi line 548. process_bug.cgi: Use of uninitialized value in string ne at Bugzilla/Bug.pm line 2660. This "--do_not_change--" string is annoying and calling _remove_remaining_time() once for all bugs is clearly wrong as you cannot do one check for all bugs (they all have different remaining time). Each bug should have its own check. But for now, we should focus on the new regression where the remaining time is not set to 0 when editing a single bug. Fix that and I will r+ your patch. Also, note that trying to pass a timetracking field to process_bug.cgi when you are not in the timetracking group throws an error even if it has the same value as the current one, because _check_foo() returns undef if you are not in that group and so it complains that you tried to changed the value to "undef". Wouldn't it be simpler to ignore this change instead of throwing an error?
Attachment #272427 - Flags: review?(LpSolit) → review-
(In reply to comment #4) > For some reason, the remaining time is no longer reset to 0 when closing a > single bug. Okay, I'll fix that. > [snip]_check_foo() returns undef if you are not in that > group and so it complains that you tried to changed the value to "undef". > Wouldn't it be simpler to ignore this change instead of throwing an error? check_can_change *should* be ignoring it, because it should register as not having changed. The undef error must be from the validators themselves.
Attached patch v3 (obsolete) — — Splinter Review
This should fix *all* the problems you mentioned above, including the mass-change (although I didn't test mass-change).
Attachment #272427 - Attachment is obsolete: true
Attachment #273070 - Flags: review?(LpSolit)
Comment on attachment 273070 [details] [diff] [review] v3 >Index: process_bug.cgi >-# Validate all timetracking fields >-foreach my $field ("estimated_time", "work_time", "remaining_time") { The 'work_time' field is not validated anymore. You can inject all what you want into the DB now. >+ # Every bug that's transitioning to FIXED gets its time zeroed. >+ # If it was already FIXED, we shouldn't zero it. >+ foreach my $b (@$bug_objects) { >+ if ($b->resolution ne 'FIXED') { >+ $b->_zero_remaining_time; > } > } Huh?? Where does this rule come from? The resolution of the bug has nothing to do here. What is important is that the new bug status is a closed one which is different from the previous one. This means that RESO FIXED -> CLOSED FIXED should reset it, but not RESO INVA -> RESO WFM. >Index: Bugzilla/Bug.pm > sub _check_deadline { >+ return undef if !$date; > my $tt_group = Bugzilla->params->{"timetrackinggroup"}; >+ my $current = ref $invocant ? $invocant->deadline : undef; >+ return $current unless $tt_group && Bugzilla->user->in_group($tt_group); IMO, you should first check if the user belongs to the timetracking group, and return $current if he doesn't, and then return undef if no time is given. Else the same problem as before would occur. I didn't test your patch yet, so maybe I will find more later.
Attachment #273070 - Flags: review?(LpSolit) → review-
Attached patch v4 (obsolete) — — Splinter Review
Ah, thanks for all those things! :-) I fixed them all in this version, which I've also tested.
Attachment #273070 - Attachment is obsolete: true
Attachment #273776 - Flags: review?(LpSolit)
Comment on attachment 273776 [details] [diff] [review] v4 >Index: process_bug.cgi > sub _remove_remaining_time { >+ # Every bug that's transitioning to closed gets its time zeroed. >+ # If it was already closed, we shouldn't zero it. >+ foreach my $b (@$bug_objects) { >+ $b->_zero_remaining_time if $b->isopened; > } We are not consistent here. In 3.0, bugs moved to RESOLVED and CLOSED had their remaining time zeroed. In 3.1, I changed it to zero it everytime we move to a new closed state (RESOLVED -> VERIFIED, VERIFIED -> ANY_CLOSED_STATE) as RESOLVED and CLOSED are no longer hardcoded. And now, you zero it only if moving from an open state to a closed state. check_can_change_field() sets remove_remaining_time = 1 everytime the resolution is changed to another closed state, and that's the job of _remove_remaining_time() to remove the remaining time in the appropriate bugs. So we should decide which behavior is expected: 1) If we only want to zero it during open -> closed transitions, then what you wrote above is fine, but $vars->{'message'} = "remaining_time_zeroed"; should be moved in the |if $b->isopened| block: foreach my $b (@$bug_objects) { if ($b->isopened) { $b->_zero_remaining_time; $vars->{'message'} = "remaining_time_zeroed"; } } else you will set $vars->{'message'} even if all bugs were previously in a closed state (meaning that no remaining time has been zeroed despite the message saying so). 2) If we want to zero it everytime we moved to another closed state, then you should change your test to something like: if ($b->bug_status != <new_status>) { $b->_zero_remaining_time; $vars->{'message'} = "remaining_time_zeroed"; } I'm fine with both. I have a preference for 1), though (which means reverting to the 2.x behavior were RESOLVED -> CLOSED transitions were ignored). We have to discuss about that. >+ if (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'}) >+ && defined $cgi->param('remaining_time') >+ && $cgi->param('remaining_time') > 0) >+ { >+ $cgi->param('remaining_time', 0); >+ $vars->{'message'} = "remaining_time_zeroed"; > } As said above, $vars->{'message'} = "remaining_time_zeroed"; is at the wrong place for the reason given above. Moreover, this whole block can go away as we don't care about $cgi->param('remaining_time') anymore, right? This would fix the annoying process_bug.cgi: Argument "--do_not_change--" isn't numeric in numeric gt (>) at /var/www/html/bugzilla/process_bug.cgi line 563. error message. >Index: Bugzilla/Bug.pm >+sub set_estimated_time { $_[0]->set('estimated_time', $_[1]); } >+sub set_remaining_time { $_[0]->set('remaining_time', $_[1]); } There is a problem with these 2 methods. They both call check_can_change_field(), as expected, but we are filling the web server error log with this error: process_bug.cgi: Use of uninitialized value in string ne at Bugzilla/Bug.pm line 2673. The problem comes from check_can_change_field(): # numeric fields need to be compared using == } elsif (($field eq 'estimated_time' || $field eq 'remaining_time') && $newvalue ne $data->{'dontchange'} && $oldvalue == $newvalue) process_bug.cgi calls check_can_change_field() with $data defined, but Bug.pm doesn't define it and so we cannot compare $newvalue against "--do_not_change--". We have to fix this problem one way or another. Holding my r+ till these problems are discussed, respectively addressed.
Attached patch v5 (obsolete) — — Splinter Review
Okay, I resolved both issues. I think it makes sense to zero the time when moving from any closed state to any other closed state. For example, from RESOLVED -> VERIFIED is the time for QA. And from VERIFIED -> CLOSED is the time for management or shipping or whatever people used CLOSED for. We only show the message if we truly removed time. process_bug itself checks dontchange now, so we don't have to check it inside of check_can_change_field anymore. So I just removed that line entirely.
Attachment #273776 - Attachment is obsolete: true
Attachment #274146 - Flags: review?(LpSolit)
Attachment #273776 - Flags: review?(LpSolit)
Attached patch v6 — — Splinter Review
Fix a few things pointed out by LpSolit on IRC.
Attachment #274146 - Attachment is obsolete: true
Attachment #274162 - Flags: review?(LpSolit)
Attachment #274146 - Flags: review?(LpSolit)
Comment on attachment 274162 [details] [diff] [review] v6 r=LpSolit
Attachment #274162 - Flags: review?(LpSolit) → review+
Flags: approval+
Checking in process_bug.cgi; /cvsroot/mozilla/webtools/bugzilla/process_bug.cgi,v <-- process_bug.cgi new revision: 1.380; previous revision: 1.379 done Checking in Bugzilla/Bug.pm; /cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v <-- Bug.pm new revision: 1.194; previous revision: 1.193 done Checking in Bugzilla/Object.pm; /cvsroot/mozilla/webtools/bugzilla/Bugzilla/Object.pm,v <-- Object.pm new revision: 1.18; previous revision: 1.17 done Checking in template/en/default/global/messages.html.tmpl; /cvsroot/mozilla/webtools/bugzilla/template/en/default/global/messages.html.tmpl,v <-- messages.html.tmpl new revision: 1.60; previous revision: 1.59 done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Blocks: 389916
Blocks: 402438
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: