From f77a2a3172df20f850d7f8093cabf9919cbdea63 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Tue, 12 Feb 2008 07:35:12 +0000 Subject: [PATCH] =?utf8?q?Bug=20384009:=20Global=20fields=20(priority,=20s?= =?utf8?q?everity,=20OS,=20and=20platform)=20are=20required=20when=20using?= =?utf8?q?=20WebService=20instead=20of=20using=20the=20defaults=20-=20Patc?= =?utf8?q?h=20by=20Fr=C3=83=C2=A9d=C3=83=C2=A9ric=20Buclin=20=20r/a=3Dmkanat?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Bugzilla/Bug.pm | 23 +++++++++++++++-------- Bugzilla/WebService/Bug.pm | 14 +++++++++----- email_in.pl | 28 ---------------------------- 3 files changed, 24 insertions(+), 41 deletions(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 1c3dc99aee..80026000d2 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -99,13 +99,8 @@ sub DB_COLUMNS { } use constant REQUIRED_CREATE_FIELDS => qw( - bug_severity - comment component - op_sys - priority product - rep_platform short_desc version ); @@ -245,11 +240,23 @@ sub new { # C - For time-tracking. Will be ignored for the same # reasons as C. 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. diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index ba1c01e989..0313d76d5f 100755 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -116,11 +116,6 @@ sub create { $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'}; @@ -462,6 +457,15 @@ in them. The error message will have more details. =back +=item B + +=over + +=item Before B<3.0.4>, parameters marked as B were actually +B, due to a bug in Bugzilla. + +=back + =back diff --git a/email_in.pl b/email_in.pl index b0895bda9b..5fd28337e5 100644 --- a/email_in.pl +++ b/email_in.pl @@ -54,25 +54,6 @@ use Bugzilla::Util; # 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. @@ -179,15 +160,6 @@ sub post_bug { 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}); -- 2.47.2