Closed Bug 252159 Opened 20 years ago Closed 20 years ago

centralize time validation

Categories

(Bugzilla :: Bugzilla-General, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: michetti, Assigned: michetti)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 4 obsolete files)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a2) Gecko/20040612 Firefox/0.8.0+ Build Identifier: maybe is a good idea to centralize the validation of time fields such as worked time or estimated time in a function Reproducible: Always Steps to Reproduce:
Blocks: 252151
Yeah, there's code at least in two places in process_bug.cgi -- it's easy to find it, just grep for 99999.99 -- agh :-P
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 153804 [details] [diff] [review] implements validateTime to centralize time validation >Index: post_bug.cgi Bugzilla::Bug::validateTime($est_time,'estimated_time'); [nit] space after the comma >Index: process_bug.cgi Bugzilla::Bug::validateTime($er_time,$field); [ditto] >Index: Bugzilla/Bug.pm > 1; >+ >+sub validateTime{ >+ my ($time,$field) = @_; >+ if ($time > 99999.99 || $time < 0 || !($time =~ /^(?:\d+(?:\.\d*)?|\.\d+)$/)){ >+ ThrowUserError("need_positive_number",{field => "$field"}); >+ } >+} This function should be named ValidateTime (it's not a method, so it uses this weird casing that EmitDependList does, I guess). It should also appear *before* the 1; up there -- right before AUTOLOAD, to be precise.
Attachment #153804 - Flags: review-
Assignee: justdave → michetti
Attached patch patch 1 with modifications (obsolete) — Splinter Review
Attachment #153804 - Attachment is obsolete: true
Attached patch no tabs (obsolete) — Splinter Review
Attachment #153808 - Attachment is obsolete: true
Comment on attachment 153812 [details] [diff] [review] no tabs >Index: process_bug.cgi >+ Bugzilla::Bug::validateTime($::FORM{'work_time'},'work_time'); Please test and read short patches before attaching, you forgot to update this call :-)
Attachment #153812 - Flags: review-
Attached patch again (obsolete) — Splinter Review
Attachment #153812 - Attachment is obsolete: true
Comment on attachment 153839 [details] [diff] [review] again >Index: process_bug.cgi >+ Bugzilla::Bug::validateTime($::FORM{'work_time'}, 'work_time'); No, not the space after the comma (or that too), but the method name: ValidateTime, not validateTime.
Attachment #153839 - Flags: review-
Attached patch ...Splinter Review
Attachment #153839 - Attachment is obsolete: true
Comment on attachment 153900 [details] [diff] [review] ... Looks good!
Attachment #153900 - Flags: review+
Status: NEW → ASSIGNED
Flags: approval?
Flags: approval? → approval+
OS: Linux → All
Hardware: PC → All
Target Milestone: --- → Bugzilla 2.20
/cvsroot/mozilla/webtools/bugzilla/post_bug.cgi,v <-- post_bug.cgi new revision: 1.90; previous revision: 1.89 /cvsroot/mozilla/webtools/bugzilla/process_bug.cgi,v <-- process_bug.cgi new revision: 1.208; previous revision: 1.207 /cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v <-- Bug.pm new revision: 1.38; previous revision: 1.37 Thanks!
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Note that the patch checked in included an "abort" to the ThrowUserError call, which was missing in any case from the original code -- when validating work time the table lock is held.
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: