Closed Bug 1140575 Opened 9 years ago Closed 9 years ago

Comment-creation WebService API should allow tags to be specified

Categories

(Bugzilla :: WebService, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 6.0

People

(Reporter: mcote, Assigned: dkl)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Spun off of bug 975339, which is about the UI.  This bug is to add the ability to specify one or more tags to the comment-creation WebService API.

Marking this as a blocker to the other, since it's likely we would fix this before the UI, so the modifications to Bugzilla core will happen here.
(In reply to Mark Côté [:mcote] from comment #0)
> Marking this as a blocker to the other, since it's likely we would fix this
> before the UI, so the modifications to Bugzilla core will happen here.

Except that the comment will be submitted with other bug changes, not with new tags. So that's not the same code.
No longer blocks: 975339
Severity: normal → enhancement
Attached patch 1140575_1.patch (obsolete) — Splinter Review
Assignee: webservice → dkl
Status: NEW → ASSIGNED
Attachment #8599455 - Flags: review?(glob)
Attached patch 1140575_2.patchSplinter Review
This has been revised to use Bug->set_all and Bug->update for adding comment tags to a new comment. This should allow the backend to be set up for adding the front end bits later for adding comment tags to a new comment.

dkl
Attachment #8599455 - Attachment is obsolete: true
Attachment #8599455 - Flags: review?(glob)
Attachment #8600024 - Flags: review?(glob)
Blocks: 975339
Comment on attachment 8600024 [details] [diff] [review]
1140575_2.patch

Review of attachment 8600024 [details] [diff] [review]:
-----------------------------------------------------------------

much nicer than the previous patch!

r=glob, with issues fixed on commit.

::: Bugzilla/Bug.pm
@@ +814,5 @@
> +    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];

nit: missing a space before ]

@@ +815,5 @@
> +
> +    # 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 || [] }) {

you don't need "|| []" because the previous line ensured it's a ref

@@ +1060,5 @@
>                               $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}};

move ->update() outside of the foreach loop, and add || [] to guard against casting undef as an array

@@ +2459,4 @@
>                is_markdown => $params->{'comment'}->{'is_markdown'} });
>      }
>  
> +    if (exists $params->{comment_tags} && Bugzilla->user->can_tag_comments()) {

you're using "exists" here, but "defined" earlier.  perform the same check both places.

::: docs/en/rst/api/core/v1/comment.rst
@@ +142,5 @@
> +ids           array    List of integer bug IDs to add the comment to.
> +**comment**   string   The comment to append to the bug. If this is empty
> +                       or all whitespace, an error will be thrown saying that you
> +                       did not set the ``comment`` parameter.
> +comment_tags  array    An array of comment tags to add to the new comment.

this should read "Array of strings to add as comment tags" or similar (ie. indicate that we want strings)
Attachment #8600024 - Flags: review?(glob) → review+
Flags: approval?
Flags: approval? → approval+
Target Milestone: --- → Bugzilla 6.0
To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
   e4362da..f805627  master -> master
Status: ASSIGNED → RESOLVED
Closed: 9 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: