}
use constant REQUIRED_CREATE_FIELDS => qw(
- bug_severity
- comment
component
- op_sys
- priority
product
- rep_platform
short_desc
version
);
# C<deadline> - For time-tracking. Will be ignored for the same
# reasons as C<estimated_time>.
sub create {
- my $class = shift;
+ my ($class, $params) = @_;
my $dbh = Bugzilla->dbh;
- $class->check_required_create_fields(@_);
- my $params = $class->run_create_validators(@_);
+ # These fields have default values which we can use if they are undefined.
+ $params->{bug_severity} = Bugzilla->params->{defaultseverity}
+ unless defined $params->{bug_severity};
+ $params->{priority} = Bugzilla->params->{defaultpriority}
+ unless defined $params->{priority};
+ $params->{op_sys} = Bugzilla->params->{defaultopsys}
+ unless defined $params->{op_sys};
+ $params->{rep_platform} = Bugzilla->params->{defaultplatform}
+ unless defined $params->{rep_platform};
+ # Make sure a comment is always defined.
+ $params->{comment} = '' unless defined $params->{comment};
+
+ $class->check_required_create_fields($params);
+ $params = $class->run_create_validators($params);
# These are not a fields in the bugs table, so we don't pass them to
# insert_create_data.
$field_values{$field_name} = $params->{$field};
}
- # Make sure all the required fields are in the hash.
- foreach my $field (Bugzilla::Bug::REQUIRED_CREATE_FIELDS) {
- $field_values{$field} = undef unless exists $field_values{$field};
- }
-
# WebService users can't set the creation date of a bug.
delete $field_values{'creation_ts'};
=back
+=item B<History>
+
+=over
+
+=item Before B<3.0.4>, parameters marked as B<Defaulted> were actually
+B<Required>, due to a bug in Bugzilla.
+
+=back
+
=back
# in a message. RFC-compliant mailers use this.
use constant SIGNATURE_DELIMITER => '-- ';
-# These fields must all be defined or post_bug complains. They don't have
-# to have values--they just have to be defined. There's not yet any
-# way to require custom fields have values, for enter_bug, so we don't
-# have to worry about those yet.
-use constant REQUIRED_ENTRY_FIELDS => qw(
- reporter
- short_desc
- product
- component
- version
-
- assigned_to
- rep_platform
- op_sys
- priority
- bug_severity
- bug_file_loc
-);
-
# Fields that must be defined during process_bug. They *do* have to
# have values. The script will grab their values from the current
# bug object, if they're not specified.
debug_print('Posting a new bug...');
- $fields{'rep_platform'} ||= Bugzilla->params->{'defaultplatform'};
- $fields{'op_sys'} ||= Bugzilla->params->{'defaultopsys'};
- $fields{'priority'} ||= Bugzilla->params->{'defaultpriority'};
- $fields{'bug_severity'} ||= Bugzilla->params->{'defaultseverity'};
-
- foreach my $field (REQUIRED_ENTRY_FIELDS) {
- $fields{$field} ||= '';
- }
-
my $cgi = Bugzilla->cgi;
foreach my $field (keys %fields) {
$cgi->param(-name => $field, -value => $fields{$field});