Closed Bug 352695 Opened 18 years ago Closed 18 years ago

Custom select fields are mandatory on bug creation (despite they shouldn't be)

Categories

(Bugzilla :: Creating/Changing Bugs, defect)

2.23
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 3.0

People

(Reporter: LpSolit, Assigned: bugzilla-mozilla)

Details

Attachments

(1 file, 1 obsolete file)

Try hacking the URL and don't include a custom select field. You get an error thrown by the validator which complains that you didn't give a valid value for this field. We could fix Bugzilla::Bug::_check_select_field() to return the default value if no value is given, except that this means hardcoding '---' in Bug.pm. I wonder if we should set '---' as default in the DB schema.
The solution is just to not pass the custom fields in, I think, if they're undef. But just those fields, because other fields should still be passed in, even if they're undef.

It should be an easy fix to the map().
Flags: blocking3.0?
Flags: blocking3.0? → blocking3.0+
Assignee: create-and-change → bugzilla-mozilla
Attached patch Patch v1 (obsolete) — Splinter Review
Attachment #242545 - Flags: review?(mkanat)
Status: NEW → ASSIGNED
Comment on attachment 242545 [details] [diff] [review]
Patch v1

>+# Undefined custom single select fields are not allowed as undefined is not a
>+# legal value.

Nit: I don't like the "are not allowed" part. This makes me think that I have to define them, always. Maybe should we only say that they are ignored.


>+my @bug_fields = grep { $_->type != FIELD_TYPE_SINGLE_SELECT
>+                        || defined $cgi->param($_->name) } @custom_bug_fields;

err... Why not: grep {defined $cgi->param($_->name)} @custom_bug_fields; only? I didn't test your patch, but I think that all undefined custom fields can be safely ignored.
Attached patch Patch v2Splinter Review
Changes:
 - Better comment, hopefully
 - Ignores all undefined custom field codes (works)
Attachment #242545 - Attachment is obsolete: true
Attachment #242907 - Flags: review?(LpSolit)
Attachment #242545 - Flags: review?(mkanat)
Comment on attachment 242907 [details] [diff] [review]
Patch v2

>+my @bug_fields = grep { defined $cgi->param($_->name) } @custom_bug_fields;
>+@bug_fields = map { $_->name } @bug_fields;

Nit: you could do a *tiny* simplification by shifting these two lines:

  my @bug_fields = map { $_->name } @custom_bug_fields;
  @bug_fields = grep { defined $cgi->param($_) } @bug_fields;

(we avoid one ->name)

Anyway, your patch is working correctly. r=LpSolit
Attachment #242907 - Flags: review?(LpSolit) → review+
Flags: approval?
Flags: approval? → approval+
Checking in post_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/post_bug.cgi,v  <--  post_bug.cgi
new revision: 1.181; previous revision: 1.180
done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: