NAME

BZ::Client::Bug::Comment - Client side representation of an Comment on a Bug in Bugzilla

VERSION

version 4.4004

SYNOPSIS

This class provides methods for accessing and managing comments in Bugzilla. Instances of this class are returned by BZ::Client::Bug::Comment::get.

my $client = BZ::Client->new( url       => $url,
                              user      => $user,
                              password  => $password );

my $comments = BZ::Client::Bug::Comment->get( $client, $ids );

CLASS METHODS

This section lists the class methods, which are available in this module.

get

my $comments = BZ::Client::Bug::Comment->get( $client, 1234 );
my $comments = BZ::Client::Bug::Comment->get( $client, { ids => \@list, commend_ids => \@list } );

This allows you to get data about comments, given a list of bugs and/or comment ids.

Actual Bugzilla API method is "comments".

History

Added in Bugzilla 3.4

Parameters

A single scalar is considered a search for "ids", otherwise a hash reference must be provided.

Note: At least one of "ids" or "comment_ids" is required.

In addition to the parameters below, this method also accepts the standard "include_fields" in BZ::Client::Bug and "exclude_fields" in BZ::Client::Bug arguments.

ids

ids (array) - An array that can contain both bug ID's and bug aliases. All of the comments (that are visible to you) will be returned for the specified bugs.

comment_ids

comment_ids (array) - An array of integer comment ID's. These comments will be returned individually, separate from any other comments in their respective bugs.

new_since

new_since (DateTime) - If specified, the method will only return comments newer than this time. This only affects comments returned from the "ids" argument. You will always be returned all comments you request in the comment_ids argument, even if they are older than this date.

Returns

A hash reference containing two items is returned. e.g.

{

    bugs => {
        123 => \@comments,
        456 => \@comments,
    },

    comments => {
        789 => $comment,
    },

}

The Bugzilla WebService documentation doesnt state what order the comments will be in, however they seem to be returned [ oldest, newest ]. If this order is important to you, then you should sort them just to be sure.

More details on the above example:

bugs

This is used for bugs specified in "ids" parameter.

This is a hash, wherein the keys are the numeric IDs of the bugs, and the corresponding value is an array ref of comment objects.

Note that any individual bug will only be returned once, so if you specify an ID multiple times in ID's, it will still only be returned once.

comments

Each individual comment requested in "comment_ids" is returned here.

This is a hash wherein the keys are the numeric comment ID, and the corresponding value is the comment object.

A "comment" as described above is an object instance of this package i.e. BZ::Client::Bug::Comment.

Errors

100 - Invalid Bug Alias

If you specified an alias and there is no bug with that alias.

101 - Invalid Bug ID

The bug_id you specified doesn't exist in the database.

102 - Access Denied

You do not have access to the bug_id you specified.

110 - Comment Is Private

You specified the ID of a private comment in the comment_ids argument, and you are not in the "insider group" that can see private comments.

111 - Invalid Comment ID

You specified an ID in the "comment_ids" argument that is invalid--either you specified something that wasn't a number, or there is no comment with that ID.

add

This allows you to add a comment to a bug in Bugzilla.

Actual Bugzilla API method is "add_comment".

History

Added in Bugzilla 3.2.

Modified to return the new comment's ID in Bugzilla 3.4

Modified to throw an error if you try to add a private comment but can't, in Bugzilla 3.4.

Parameters

An instance of this package or a hash containing:

id

id (int or string) Required - The ID or alias of the bug to append a comment to.

comment

comment (string) Required - 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.

is_private

is_private (boolean) - If set to true, the comment is private, otherwise it is assumed to be public.

Before Bugzilla 3.6, the "is_private argument" was called private, and you can still call it private for backwards-compatibility purposes if you wish.

work_time

work_time (double) - Adds this many hours to the "Hours Worked" on the bug. If you are not in the time tracking group, this value will be ignored.

Returns

The id of the newly-created comment.

Errors

54 - Hours Worked Too Large

You specified a "work_time" larger than the maximum allowed value of 99999.99.

100 - Invalid Bug Alias

If you specified an alias and there is no bug with that alias.

101 - Invalid Bug ID

The ID you specified doesn't exist in the database.

109 - Bug Edit Denied

You did not have the necessary rights to edit the bug.

113 - Can't Make Private Comments

You tried to add a private comment, but don't have the necessary rights.

114 - Comment Too Long

You tried to add a comment longer than the maximum allowed length (65,535 characters).

Before Bugzilla 3.6, error 54 and error 114 had a generic error code of 32000.

render

Returns the HTML rendering of the provided comment text.

Actual Bugzilla API method is "render_comment".

Note: this all takes place on your Bugzilla server.

History

Added in Bugzilla 5.0.

Parameters

text

text (string) Required - Text comment text to render

id

id The ID of the bug to render the comment against.

Returns

The HTML rendering

Errors

100 - Invalid Bug Alias

If you specified an alias and there is no bug with that alias.

101 - Invalid Bug ID

The bug_id you specified doesn't exist in the database.

102 - Access Denied

You do not have access to the bug_id you specified.

new

my $comment = BZ::Client::Bug::Comment->new(
                                        id         => $bug_id,
                                        comment    => $comment,
                                        is_private => 1 || 0,
                                        work_time  => 3.5
                                      );

Creates a new instance with the given details. Doesn't actually touch your Bugzilla Server - see "add" for that.

INSTANCE METHODS

This section lists the modules instance methods.

bug_id

bug_id (int) - The ID of the bug that this comment is on when reading

bug_id (int or string) - The ID or alias of the bug to append a comment to when writing

comment

comment (string) The actual text of the comment when reading

When writing, 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.

Max length is 65,535 characters.

text

Synonym for "comment"

is_private

is_private (boolean) - If set to true, the comment is private, otherwise it is assumed to be public.

Read and Write.

work_time

work_time (double) - Adds this many hours to the "Hours Worked" on the bug. If you are not in the time tracking group, this value will be ignored.

Max value is 99999.99

id

id (int) The globally unique ID for the comment.

Read only.

attachment_id

attachment_id (int) If the comment was made on an attachment, this will be the ID of that attachment. Otherwise it will be null.

Read only.

Added to the return value in Bugzilla 3.6

count

count (int) - The number of the comment local to the bug. The Description is 0, comments start with 1.

Read only.

Added to the return value in Bugzilla 4.4.

creator

creator (string) - The login name of the comment's author.

Also returned as "author", for backwards-compatibility with older Bugzillas. (However, this backwards-compatibility will go away in Bugzilla 5.0)

In bugzilla 4.0, the "author" return value was renamed to "creator".

author

See creator

time

time (DateTime) - The time (in Bugzilla's timezone) that the comment was added.

Read only.

creation_time

creation_time (DateTime) - This is exactly same as the "time" key. Use this field instead of "time" for consistency with other methods including "get" and "attachments". For compatibility, /time is still usable. However, please note that /time may be deprecated and removed in a future release of Bugzilla.

Read only.

Added in Bugzilla 4.4.

SEE ALSO

BZ::Client, BZ::Client::API, Bugzilla API

AUTHORS

  • Dean Hamstead <dean@bytefoundry.com.au>

  • Jochen Wiedmann <jochen.wiedmann@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by Dean Hamstad.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.