Closed Bug 371070 Opened 17 years ago Closed 17 years ago

Move basic validations from process_bug.cgi into Bugzilla::Bug

Categories

(Bugzilla :: Creating/Changing Bugs, enhancement)

2.23.4
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 3.2

People

(Reporter: mkanat, Assigned: mkanat)

References

Details

Attachments

(1 file, 1 obsolete file)

This is just like the very first thing we did to Bug.pm-ize post_bug. Some fields have very simple validators, like the "comment" field, and we can just directly use our Bugzilla::Bug->_check functions in process_bug to simplify those checks.
Severity: normal → enhancement
For process_bug, certain fields can be validated once, even on a multiple-bug change, and they are simple validations. Those are the ones we're going to move, here.
Summary: Move some basic validations from process_bug.cgi into Bugzilla::Bug → Move simple validations from process_bug.cgi into Bugzilla::Bug for fields that don't depend on other fields
Summary: Move simple validations from process_bug.cgi into Bugzilla::Bug for fields that don't depend on other fields → Move basic validations from process_bug.cgi into Bugzilla::Bug
Attached patch v1 (obsolete) — Splinter Review
This is really, really basic stuff. It just gets some of the validations out of process_bug and into Bugzilla::Bug. It gave me a feel for where to go next, too.
Assignee: create-and-change → mkanat
Status: NEW → ASSIGNED
Attachment #255845 - Flags: review?(LpSolit)
Blocks: 283926
Blocks: 371774
Comment on attachment 255845 [details] [diff] [review]
v1

>Index: process_bug.cgi

> foreach my $field ("estimated_time", "work_time", "remaining_time") {
>     if (defined $cgi->param($field)) {
>-        my $er_time = trim($cgi->param($field));
>-        if ($er_time ne $cgi->param('dontchange')) {
>-            Bugzilla::Bug::ValidateTime($er_time, $field);
>-        }
>+        $cgi->param($field, $bug->_check_time($cgi->param($field), $field));
>     }
> }

If you are changing several bugs at once, you get an error:

 The value '--do_not_change--' in the Orig. Est. field is not a numeric value.

You have to do this check only if ($er_time ne $cgi->param('dontchange')).


>+    my $prod = $bug->_check_product($cgi->param('product'));

Nit: please update $cgi->param('product') with $prod->name, as you did for the component.



>Index: Bugzilla/Bug.pm

> sub _check_bug_file_loc {
>     my ($invocant, $url) = @_;
>+    $url = '' if !defined($url);

Are you sure this won't overwrite the URL field when changing several bugs at once? Most of the time, we ignore undefined fields, but consider empty fields as their new value.


>+    # Creation-only checks
>+    if (!ref $invocant) {
>+        $comment = ' ' if $comment eq '' && !ref($invocant);

You already know that !ref($invocant) is true. That's the block you are in.
Attachment #255845 - Flags: review?(LpSolit) → review-
Attached patch v2Splinter Review
URL can't be changed in a mass-change.

I fixed everything else.
Attachment #255845 - Attachment is obsolete: true
Attachment #257373 - Flags: review?(LpSolit)
Comment on attachment 257373 [details] [diff] [review]
v2

Looks good. r=LpSolit
Attachment #257373 - 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.352; previous revision: 1.351
done
Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v  <--  Bug.pm
new revision: 1.173; previous revision: 1.172
done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: