Closed Bug 936241 Opened 11 years ago Closed 11 years ago

Bug.create doesn't allow tracking flags to be set, but Bug.update does

Categories

(bugzilla.mozilla.org :: API, defect)

Development
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: erik.bryn, Assigned: dkl)

Details

Attachments

(1 file)

I noticed that Bug.create and Bug.update's params handling behavior differs with regards to custom fields. Ember.create and Ember.show return custom field names prefixed with `cf_`, so I submit custom field values with that param name. I'm unable to set tracking flags like `cf_tracking_firefox24` with Bug.create, but can with Bug.update.
Bug.create fails with this error message: cf_tracking_firefox24 is not a valid parameter for the Bugzilla::Bug::create function.
Updating the summary as it doesn't matter whether submitted as `cf_tracking_firefox24` or `tracking_firefox24`.
Summary: Bug.create doesn't allow custom fields to be set with cf_ prefixed field names, Bug.update does → Bug.create doesn't allow some custom fields to be set, but Bug.update does
Summary: Bug.create doesn't allow some custom fields to be set, but Bug.update does → Bug.create doesn't allow tracking flags to be set, but Bug.update does
Attached patch 936241_1.patchSplinter Review
post_bug.cgi was skipping over extension fields when calling Bugzilla::Bug->create but Bug.create was not. So I am hooking into bug_end_of_create_validators to cache away the tracking flag params before $class->insert_create_data($params) in Bugzilla::Bug::create. Then the params are used later in the bug_end_of_create hook. dkl
Assignee: nobody → dkl
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #833182 - Flags: review?(glob)
Erik. I went ahead and pushed this change to bugzilla-dev.allizom.org for your verification while awaiting code review. Please let me know if this fixes your issue. Committing to: bzr+ssh://dlawrence%40mozilla.com@bzr.mozilla.org/bmo/4.2-dev modified post_bug.cgi modified extensions/TrackingFlags/Extension.pm Committed revision 8595. dkl
Flags: needinfo?(erik.bryn)
It's working. Thanks!
Flags: needinfo?(erik.bryn)
Comment on attachment 833182 [details] [diff] [review] 936241_1.patch Review of attachment 833182 [details] [diff] [review]: ----------------------------------------------------------------- r=glob, with the following to be addressed on commit. ::: extensions/TrackingFlags/Extension.pm @@ +461,5 @@ > + # If we are coming from Bug.create, we need to pull them from the request_cache > + my $cache = Bugzilla->request_cache->{tracking_flags_create_params}; > + if ($cache) { > + map { $params->{$_} => $cache->{$_} } keys %$cache; > + } bug_end_of_create_validators is called in both cases, so {tracking_flags_create_params} is populated in both cases. may as well stop reading from input_params and just use that the "$cache" hashref directly as params. @@ +590,4 @@ > } > } > > +sub bug_end_of_create_validators { please add a comment here to explain why this happens and where it's consumed. @@ +597,5 @@ > + 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}; use $flag_name everywhere
Attachment #833182 - Flags: review?(glob) → review+
Committing to: bzr+ssh://dlawrence%40mozilla.com@bzr.mozilla.org/bmo/4.2 modified post_bug.cgi modified Bugzilla/WebService/Bug.pm modified extensions/TrackingFlags/Extension.pm Committed revision 9151.
Status: ASSIGNED → RESOLVED
Closed: 11 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: