summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-11-18 20:48:05 +0100
committerDave Lawrence <dlawrence@mozilla.com>2013-11-18 20:48:05 +0100
commita1ca30a6ae868e80d8af50f94638733b6b822958 (patch)
tree1207aa83917706c2df7ae1d4a4893ea0f0df345e
parent3e5fc54202f854e76b139ec71fd78e91029dc7d2 (diff)
downloadbugzilla-a1ca30a6ae868e80d8af50f94638733b6b822958.tar.gz
bugzilla-a1ca30a6ae868e80d8af50f94638733b6b822958.tar.xz
Bug 936241 - Bug.create doesn't allow tracking flags to be set, but Bug.update does
r=glob
-rw-r--r--Bugzilla/WebService/Bug.pm6
-rw-r--r--extensions/TrackingFlags/Extension.pm26
-rwxr-xr-xpost_bug.cgi4
3 files changed, 29 insertions, 7 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index aa5fd49c4..707e0d42d 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -694,6 +694,12 @@ sub create {
}
Bugzilla->login(LOGIN_REQUIRED);
+
+ # Some fields cannot be sent to Bugzilla::Bug->create
+ foreach my $key (qw(login password token)) {
+ delete $params->{$key};
+ }
+
$params = Bugzilla::Bug::map_fields($params);
my $bug = Bugzilla::Bug->create($params);
Bugzilla::BugMail::Send($bug->bug_id, { changer => $bug->reporter });
diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm
index d1cd9eb8e..7d8f8c401 100644
--- a/extensions/TrackingFlags/Extension.pm
+++ b/extensions/TrackingFlags/Extension.pm
@@ -452,10 +452,12 @@ sub _tracking_flags_search_nonchanged {
sub bug_end_of_create {
my ($self, $args) = @_;
- my $bug = $args->{'bug'};
- my $timestamp = $args->{'timestamp'};
- my $params = Bugzilla->input_params;
- my $user = Bugzilla->user;
+ my $bug = $args->{'bug'};
+ my $timestamp = $args->{'timestamp'};
+ my $user = Bugzilla->user;
+
+ my $params = Bugzilla->request_cache->{tracking_flags_create_params};
+ return if !$params;
my $tracking_flags = Bugzilla::Extension::TrackingFlags::Flag->match({
product => $bug->product,
@@ -581,6 +583,22 @@ sub bug_end_of_update {
}
}
+sub bug_end_of_create_validators {
+ my ($self, $args) = @_;
+ my $params = $args->{params};
+
+ # We need to stash away any params that are setting/updating tracking
+ # flags early on. Otherwise set_all or insert_create_data will complain.
+ my @tracking_flags = Bugzilla::Extension::TrackingFlags::Flag->get_all;
+ my $cache = Bugzilla->request_cache->{tracking_flags_create_params} ||= {};
+ foreach my $flag (@tracking_flags) {
+ my $flag_name = $flag->name;
+ if (defined $params->{$flag_name}) {
+ $cache->{$flag_name} = delete $params->{$flag_name};
+ }
+ }
+}
+
sub mailer_before_send {
my ($self, $args) = @_;
my $email = $args->{email};
diff --git a/post_bug.cgi b/post_bug.cgi
index 87ebba9c4..7907d7037 100755
--- a/post_bug.cgi
+++ b/post_bug.cgi
@@ -98,9 +98,7 @@ $template->process($format->{'template'}, $vars, \$comment)
|| ThrowTemplateError($template->error());
# Include custom fields editable on bug creation.
-my @custom_bug_fields = grep {$_->type != FIELD_TYPE_MULTI_SELECT
- && $_->type != FIELD_TYPE_EXTENSION
- && $_->enter_bug}
+my @custom_bug_fields = grep {$_->type != FIELD_TYPE_MULTI_SELECT && $_->enter_bug}
Bugzilla->active_custom_fields;
# Undefined custom fields are ignored to ensure they will get their default