From b34fcddb0e8c135d4f2feb9686223fddd9a8e7df Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 11 May 2015 16:30:39 +0100 Subject: Bug 1161716: backport bug 1140575 to allow adding comment tags via webservice API when creating/updating --- Bugzilla/WebService/Bug.pm | 47 +++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'Bugzilla/WebService') diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index b76c30b19..2edd2f3d0 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -1044,7 +1044,7 @@ sub update_attachment { sub add_comment { my ($self, $params) = @_; - + # BMO: Don't allow updating of bugs if disabled if (Bugzilla->params->{disable_bug_updates}) { ThrowErrorPage('bug/process/updates-disabled.html.tmpl', @@ -1053,42 +1053,46 @@ sub add_comment { #The user must login in order add a comment Bugzilla->login(LOGIN_REQUIRED); - + # Check parameters - defined $params->{id} - || ThrowCodeError('param_required', { param => 'id' }); - my $comment = $params->{comment}; + defined $params->{id} + || ThrowCodeError('param_required', { param => 'id' }); + my $comment = $params->{comment}; (defined $comment && trim($comment) ne '') || ThrowCodeError('param_required', { param => 'comment' }); - + my $bug = Bugzilla::Bug->check($params->{id}); - + Bugzilla->user->can_edit_product($bug->product_id) || ThrowUserError("product_edit_denied", {product => $bug->product}); - - # Backwards-compatibility for versions before 3.6 + + # Backwards-compatibility for versions before 3.6 if (defined $params->{private}) { $params->{is_private} = delete $params->{private}; } # Append comment $bug->add_comment($comment, { isprivate => $params->{is_private}, work_time => $params->{work_time} }); - - # Capture the call to bug->update (which creates the new comment) in + + # Add comment tags + $bug->set_all({ comment_tags => $params->{comment_tags} }) + if defined $params->{comment_tags}; + + # Capture the call to bug->update (which creates the new comment) in # a transaction so we're sure to get the correct comment_id. - + my $dbh = Bugzilla->dbh; $dbh->bz_start_transaction(); - + $bug->update(); - + my $new_comment_id = $dbh->bz_last_key('longdescs', 'comment_id'); - + $dbh->bz_commit_transaction(); - + # Send mail. Bugzilla::BugMail::Send($bug->bug_id, { changer => Bugzilla->user }); - + return { id => $self->type('int', $new_comment_id) }; } @@ -3354,6 +3358,9 @@ don't want it to be assigned to the component owner. =item C (boolean) - If set to true, the description is private, otherwise it is assumed to be public. +=item C (array) - An array of strings to add as comment +tags to the description. + =item C (array) - An array of group names to put this bug into. You can see valid group names on the Permissions tab of the Preferences screen, or, if you are an administrator, @@ -3931,6 +3938,8 @@ otherwise it is assumed to be public. on the bug. If you are not in the time tracking group, this value will be ignored. +=item C (array) - Array of strings to add as comment tags for +the new comment. =back @@ -4116,6 +4125,10 @@ The comment ids must be valid for the bug being updated. Thus, it is not practical to use this while updating multiple bugs at once, as a single comment id will never be valid on multiple bugs. +=item C + +C An array of strings to add as comment tags for the new comment. + =item C C The Component the bug is in. -- cgit v1.2.3-24-g4f1b