diff options
author | David Lawrence <dkl@mozilla.com> | 2015-05-11 17:30:39 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2015-05-11 17:30:39 +0200 |
commit | b34fcddb0e8c135d4f2feb9686223fddd9a8e7df (patch) | |
tree | ab93e96fe4404d7e31e76acaf7c2ddbeb1fcd471 /Bugzilla/Bug.pm | |
parent | 1ad9a822d2aef528dd41605e4f36c044ce083d50 (diff) | |
download | bugzilla-b34fcddb0e8c135d4f2feb9686223fddd9a8e7df.tar.gz bugzilla-b34fcddb0e8c135d4f2feb9686223fddd9a8e7df.tar.xz |
Bug 1161716: backport bug 1140575 to allow adding comment tags via webservice API when creating/updating
Diffstat (limited to 'Bugzilla/Bug.pm')
-rw-r--r-- | Bugzilla/Bug.pm | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index af3f5a355..eee35360b 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -726,6 +726,7 @@ sub create { my $keywords = delete $params->{keywords}; my $creation_comment = delete $params->{comment}; my $see_also = delete $params->{see_also}; + my $comment_tags = delete $params->{comment_tags}; # We don't want the bug to appear in the system until it's correctly # protected by groups. @@ -814,7 +815,16 @@ sub create { # Insert the comment. We always insert a comment on bug creation, # but sometimes it's blank. - Bugzilla::Comment->insert_create_data($creation_comment); + my $comment = Bugzilla::Comment->insert_create_data($creation_comment); + + # Add comment tags + if (defined $comment_tags && Bugzilla->user->can_tag_comments) { + $comment_tags = ref $comment_tags ? $comment_tags : [ $comment_tags ]; + foreach my $tag (@{$comment_tags}) { + $comment->add_tag($tag) if defined $tag; + } + $comment->update(); + } # BMO - add the stash param from bug_start_of_create Bugzilla::Hook::process('bug_end_of_create', { bug => $bug, @@ -1020,7 +1030,7 @@ sub update { join(', ', @added_names)]; } - # Comments + # Comments and comment tags foreach my $comment (@{$self->{added_comments} || []}) { # Override the Comment's timestamp to be identical to the update # timestamp. @@ -1030,6 +1040,10 @@ sub update { LogActivityEntry($self->id, "work_time", "", $comment->work_time, $user->id, $delta_ts); } + foreach my $tag (@{$self->{added_comment_tags} || []}) { + $comment->add_tag($tag) if defined $tag; + } + $comment->update() if @{$self->{added_comment_tags} || []}; } # Comment Privacy @@ -2454,6 +2468,12 @@ sub set_all { work_time => $params->{'work_time'} }); } + if (defined $params->{comment_tags} && Bugzilla->user->can_tag_comments()) { + $self->{added_comment_tags} = ref $params->{comment_tags} + ? $params->{comment_tags} + : [ $params->{comment_tags} ]; + } + my %normal_set_all; foreach my $name (keys %$params) { # These are handled separately below. |