BZ::Client::Bug - Client side representation of a bug in Bugzilla
version 2.0_7
This class provides methods for accessing and managing bugs in Bugzilla.
my $client = BZ::Client->new( url => $url, user => $user, password => $password ); my $bugs = BZ::Client::Bug->get( $client, $ids );
Many Webservice methods take similar arguments. Instead of re-writing the documentation for each method, we document the parameters here, once, and then refer back to this documentation from the individual methods where these parameters are used.
Many methods return an array of structs with various fields in the structs. (For example, get in BZ::Client::Bug returns a list of bugs that have fields like id, summary, creation_time, etc.)
These parameters allow you to limit what fields are present in the structs, to possibly improve performance or save some bandwidth.
include_fields (array) - An array of strings, representing the (case-sensitive) names of fields in the return value. Only the fields specified in this hash will be returned, the rest will not be included.
If you specify an empty array, then this function will return empty hashes.
Invalid field names are ignored.
Example:
BZ::Client::User->get( $client, { ids => [1], include_fields => ['id', 'name'] })
would return something like:
[{ id => 1, name => 'user@domain.com' }]
exclude_fields (array) - An array of strings, representing the (case-sensitive) names of fields in the return value. The fields specified will not be included in the returned hashes.
If you specify all the fields, then this function will return empty hashes.
Some RPC calls support specifying sub fields. If an RPC call states that it support sub field restrictions, you can restrict what information is returned within the first field. For example, if you call Product.get with an include_fields of components.name, then only the component name would be returned (and nothing else). You can include the main field, and exclude a sub field.
Specifying fields here overrides include_fields, so if you specify a field in both, it will be excluded, not included.
BZ::Client::User->get( $client, { ids => [1], exclude_fields => ['name'] })
[{ id => 1, real_name => 'John Smith' }]
There are several shortcut identifiers to ask for only certain groups of fields to be returned or excluded.
All possible fields are returned if _all is specified in include_fields.
These fields are returned if include_fields is empty or _default is specified. All fields described in the documentation are returned by default unless specified otherwise.
These fields are not returned by default and need to be manually specified in include_fields either by field name, or using _extra.
Only custom fields are returned if _custom is specified in include_fields. This is normally specific to bug objects and not relevant for other returned objects.
BZ::Client::User->get( $client, { ids => [1], include_fields => ['_all'] })
This section lists the utility functions provided by this module.
These deal with bug-related information, but not bugs directly.
$fields = BZ::Client::Bug->fields( $client, $params ) @fields = BZ::Client::Bug->fields( $client, $params )
Get information about valid bug fields, including the lists of legal values for each field.
Added in Bugzilla 3.6
You can pass either field ids or field names.
Note: If neither ids nor names is specified, then all non-obsolete fields will be returned.
ids (array) - An array of integer field ids
names (array) - An array of strings representing field names.
In addition to the parameters above, this method also accepts the standard include_fields and exclude_fields arguments.
Returns an array or an arrayref of hashes, containing the following keys:
id (int) - An integer id uniquely identifying this field in this installation only.
type (int) The number of the fieldtype. The following values are defined:
is_custom (boolean) True when this is a custom field, false otherwise.
name (string) The internal name of this field. This is a unique identifier for this field. If this is not a custom field, then this name will be the same across all Bugzilla installations.
display_name (string) The name of the field, as it is shown in the user interface.
is_mandatory (boolean) True if the field must have a value when filing new bugs. Also, mandatory fields cannot have their value cleared when updating bugs.
This return value was added in Bugzilla 4.0.
is_on_bug_entry (boolean) For custom fields, this is true if the field is shown when you enter a new bug. For standard fields, this is currently always false, even if the field shows up when entering a bug. (To know whether or not a standard field is valid on bug entry, see "create".)
visibility_field (string) The name of a field that controls the visibility of this field in the user interface. This field only appears in the user interface when the named field is equal to one of the values in visibility_values. Can be null.
visibility_values (array) of strings This field is only shown when visibility_field matches one of these values. When visibility_field is null, then this is an empty array.
value_field (string) The name of the field that controls whether or not particular values of the field are shown in the user interface. Can be null.
This is an array of hashes, representing the legal values for select-type (drop-down and multiple-selection) fields. This is also populated for the component, version, target_milestone, and keywords fields, but not for the product field (you must use "get_accessible_products" in BZ::Client::Product for that).
For fields that aren't select-type fields, this will simply be an empty array.
Each hash has the following keys:
name (string) The actual value--this is what you would specify for this field in "create", etc.
sort_key (int) Values, when displayed in a list, are sorted first by this integer and then secondly by their name.
DEPRECATED - Use sort_key instead.
Renamed to sort_key in Bugzilla 4.2.
If "value_field" is defined for this field, then this value is only shown if the "value_field" is set to one of the values listed in this array.
Note that for per-product fields, "value_field" is set to 'product' and "visibility_values" will reflect which product(s) this value appears in.
is_active (boolean) This value is defined only for certain product specific fields such as version, target_milestone or component.
When true, the value is active, otherwise the value is not active.
Added in Bugzilla 4.4.
description (string) The description of the value. This item is only included for the keywords field.
is_open (boolean) For "bug_status" values, determines whether this status specifies that the bug is "open" (true) or "closed" (false). This item is only included for the "bug_status" field.
For "bug_status" values, this is an array of hashes that determines which statuses you can transition to from this status. (This item is only included for the "bug_status" field.)
Each hash contains the following items:
The name of the new status
comment_required (boolean) True if a comment is required when you change a bug into this status using this transition.
Errors:
You specified an invalid field name or id.
$values = BZ::Client::Bug->legal_values( $client, $field ) @values = BZ::Client::Bug->legal_values( $client, $field )
Tells you what values are allowed for a particular field.
Note: This is deprecated in Bugzilla, use "fields" instead.
The name of the field you want information about. This should be the same as the name you would use in "create", below.
If you're picking a product-specific field, you have to specify the id of the product you want the values for.
An array or arrayref of strings: the legal values for this field. The values will be sorted as they normally would be in Bugzilla.
You were required to specify a product, and either you didn't, or you specified an invalid product (or a product that you can't access).
You specified a field that doesn't exist or isn't a drop-down field.
This section lists the class methods pertaining to finding and retrieving bugs from your server.
Listed here in order of what you most likely want to do... maybe?
@bugs = BZ::Client::Bug->get( $client, \%params ); $bugs = BZ::Client::Bug->get( $client, \%params );
Gets information about particular bugs in the database.
An array of numbers and strings.
If an element in the array is entirely numeric, it represents a bug_id from the Bugzilla database to fetch. If it contains any non-numeric characters, it is considered to be a bug alias instead, and the bug with that alias will be loaded.
permissive (boolean) Normally, if you request any inaccessible or invalid bug ids, will throw an error.
If this parameter is True, instead of throwing an error we return an array of hashes with a id, faultString and faultCode for each bug that fails, and return normal information for the other bugs that were accessible.
Note: marked as EXPERIMENTAL in Bugzilla 4.4
Added in Bugzilla 3.4.
An array or arrayref of bug instance objects with the given ID's.
See "INSTANCE METHODS" for how to use them.
FIXME missing the faults return values (added in 3.4)
If you specified an alias and there is no bug with that alias.
The bug_id you specified doesn't exist in the database.
You do not have access to the bug_id you specified.
@bugs = BZ::Client::Bug->search( $client, \%params ); $bugs = BZ::Client::Bug->search( $client, \%params );
Searches for bugs matching the given parameters.
Returns an array or arrayref of bug instance objects with the given ID's.
@history = BZ::Client::Bug->history( $client, \%params ); $history = BZ::Client::Bug->history( $client, \%params );
Gets the history of changes for particular bugs in the database.
If an element in the array is entirely numeric, it represents a bug_id from the Bugzilla database to fetch. If it contains any non-numeric characters, it is considered to be a bug alias instead, and the data bug with that alias will be loaded.
An array or arrayref of hashes, containing the following keys:
id (int) The numeric id of the bug
alias (array) The alias of this bug. If there is no alias, this will be undef.
An array of hashes, each hash having the following keys:
when (dateTime) The date the bug activity/change happened.
who (string) The login name of the user who performed the bug change.
An array of hashes which contain all the changes that happened to the bug at this time (as specified by when). Each hash contains the following items:
field_name (string) The name of the bug field that has changed.
removed (string) The previous value of the bug field which has been deleted by the change.
added (string) The new value of the bug field which has been added by the change.
attachment_id (int) The id of the attachment that was changed. This only appears if the change was to an attachment, otherwise attachment_id will not be present in this hash.
The same as "get".
@bugs = BZ::Client::Bug->possible_duplicates( $client, \%params ); $bugs = BZ::Client::Bug->possible_duplicates( $client, \%params );
Allows a user to find possible duplicate bugs based on a set of keywords such as a user may use as a bug summary. Optionally the search can be narrowed down to specific products.
Added in Bugzilla 4.0.
summary (string) A string of keywords defining the type of bug you are trying to report. Required.
product (array) One or more product names to narrow the duplicate search to. If omitted, all bugs are searched.
Note that you will only be returned information about bugs that you can see. Bugs that you can't see will be entirely excluded from the results. So, if you want to see private bugs, you will have to first log in and then call this method.
You must specify a value for summary containing a string of keywords to search for duplicates.
This section lists the class methods pertaining to the creation and modification of bugs.
my $id = BZ::Client::Bug->create( $client, \%params );
Creates a new bug in your Bugzilla server and returns the bug ID.
my $id = BZ::Client::Bug->update( $client, \%params );
Allows you to update the fields of a bug.
(Your Bugzilla server may automatically sends emails out about the changes)
FIXME more details needed
@changes = BZ::Client::Bug->update_see_also( $client, \%params ); $changes = BZ::Client::Bug->update_see_also( $client, \%params );
Adds or removes URLs for the See Also field on bugs. These URLs must point to some valid bug in some Bugzilla installation or in Launchpad.
This is marked as EXPERIMENTAL in Bugzilla 4.4
An array of integers or strings. The IDs or aliases of bugs that you want to modify.
Array of strings. URLs to Bugzilla bugs. These URLs will be added to the See Also field.
If the URLs don't start with http:// or https://, it will be assumed that http:// should be added to the beginning of the string.
http://
https://
It is safe to specify URLs that are already in the See Also field on a bug as they will just be silently ignored.
An array of strings. These URLs will be removed from the See Also field. You must specify the full URL that you want removed. However, matching is done case-insensitively, so you don't have to specify the URL in exact case, if you don't want to.
If you specify a URL that is not in the See Also field of a particular bug, it will just be silently ignored. Invaild URLs are currently silently ignored, though this may change in some future version of Bugzilla.
NOTE: If you specify the same URL in both add and remove, it will be added. (That is, add overrides remove.)
A hash or hashref where the keys are numeric bug ids and the contents are a hash with one key, see_also.
see_also points to a hash, which contains two keys, added and removed.
These are arrays of strings, representing the actual changes that were made to the bug.
Here's a diagram of what the return value looks like for updating bug ids 1 and 2:
{ 1 => { see_also => { added => [(an array of bug URLs)], removed => [(an array of bug URLs)], } }, 2 => { see_also => { added => [(an array of bug URLs)], removed => [(an array of bug URLs)], } } }
This return value allows you to tell what this method actually did.
It is in this format to be compatible with the return value of a future \update method.
This method can throw all of the errors that "get" throws, plus:
You did not have the necessary rights to edit the bug.
One of the URLs you provided did not look like a valid bug URL.
You did not have the necessary rights to edit the See Also field for this bug.
Before Bugzilla 3.6, error 115 had a generic error code of 32000.
@changes = BZ::Client::Bug->update_tags( $client, \%params ); $changes = BZ::Client::Bug->update_tags( $client, \%params );
Adds or removes tags on bugs.
This is marked as UNSTABLE in Bugzilla 4.4
An array of ints and/or strings--the ids or aliases of bugs that you want to add or remove tags to. All the tags will be added or removed to all these bugs.
A hash representing tags to be added and/or removed. The hash has the following fields:
An array of strings representing tag names to be added to the bugs.
It is safe to specify tags that are already associated with the bugs as they will just be silently ignored.
An array of strings representing tag names to be removed from the bugs.
It is safe to specify tags that are not associated with any bugs as they will just be silently ignored.
A hash or hashref where the keys are numeric bug ids and the contents are a hash with one key, tags.
tags points to a hash, which contains two keys, added and removed.
{ 1 => { tags => { added => [(an array of tags)], removed => [(an array of tags)], } }, 2 => { tags => { added => [(an array of tags)], removed => [(an array of tags)], } } }
This method can throw all of the errors that "get" throws.
my $bug = BZ::Client::Bug->new( id => $id );
Creates a new bug object instance with the given ID.
Note: Doesn't actually touch your bugzilla server.
See "INSTANCE METHODS" for how to use it.
This section lists the modules instance methods.
Once you have a bug object, you can use these methods to inspect and manipulate the bug.
$id = $bug->id(); $bug->id( $id );
Gets or sets the bugs ID.
$alias = $bug->alias(); $bug->alias( $alias );
Gets or sets the bugs alias. If there is no alias or aliases are disabled in Bugzilla, this will be an empty string.
$assigned_to = $bug->assigned_to(); $bug->assigned_to( $assigned_to );
Gets or sets the login name of the user to whom the bug is assigned.
$component = $bug->component(); $bug->component( $component );
Gets or sets the name of the current component of this bug.
$dateTime = $bug->creation_time(); $bug->creation_time( $dateTime );
Gets or sets the date and time, when the bug was created.
$dupeOf = $bug->dupe_of(); $bug->dupe_of( $dupeOf );
Gets or sets the bug ID of the bug that this bug is a duplicate of. If this bug isn't a duplicate of any bug, this will be an empty int.
$isOpen = $bug->is_open(); $bug->is_open( $isOpen );
Gets or sets, whether this bug is closed. The return value, or parameter value is true (1) if this bug is open, false (0) if it is closed.
$lastChangeTime = $bug->last_change_time(); $bug->last_change_time( $lastChangeTime );
Gets or sets the date and time, when the bug was last changed.
$priority = $bug->priority(); $bug->priority( $priority );
Gets or sets the priority of the bug.
$product = $bug->product(); $bug->product( $product );
Gets or sets the name of the product this bug is in.
$resolution = $bug->resolution(); $bug->resolution( $resolution );
Gets or sets the current resolution of the bug, or an empty string if the bug is open.
$severity = $bug->severity(); $bug->severity( $severity );
Gets or sets the current severity of the bug.
$status = $bug->status(); $bug->status( $status );
Gets or sets the current status of the bug.
$summary = $bug->summary(); $bug->summary( $summary );
Gets or sets the summary of this bug.
These are implemented by other modules.
See BZ::Client::Bug::Attachment and BZ::Client::Bug::Comment
Bugzilla 5.0. introduced the search_comment_tags and update_comment_tags methods, these are yet to be specifically implemented.
search_comment_tags
update_comment_tags
BZ::Client, BZ::Client::Bug::Attachment, BZ::Client::Bug::Comment
BZ::Client::API, Bugzilla API
Dean Hamstead <dean@bytefoundry.com.au>
Jochen Wiedmann <jochen.wiedmann@gmail.com>
This software is copyright (c) 2015 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.
To install BZ::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BZ::Client
CPAN shell
perl -MCPAN -e shell install BZ::Client
For more information on module installation, please visit the detailed CPAN module installation guide.