1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Max Kanat-Alexander <mkanat@bugzilla.org>
# Mads Bondo Dydensborg <mbd@dbc.dk>
# Tsahi Asher <tsahi_75@yahoo.com>
# Noura Elhawary <nelhawar@redhat.com>
package Bugzilla::WebService::Bug;
use strict;
use base qw(Bugzilla::WebService);
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Field;
use Bugzilla::WebService::Constants;
use Bugzilla::WebService::Util qw(filter);
use Bugzilla::Bug;
use Bugzilla::BugMail;
use Bugzilla::Util qw(trim);
#############
# Constants #
#############
# This maps the names of internal Bugzilla bug fields to things that would
# make sense to somebody who's not intimately familiar with the inner workings
# of Bugzilla. (These are the field names that the WebService uses.)
use constant FIELD_MAP => {
status => 'bug_status',
severity => 'bug_severity',
description => 'comment',
summary => 'short_desc',
platform => 'rep_platform',
};
use constant PRODUCT_SPECIFIC_FIELDS => qw(version target_milestone component);
######################################################
# Add aliases here for old method name compatibility #
######################################################
BEGIN { *get_bugs = \&get }
###########
# Methods #
###########
sub comments {
my ($self, $params) = @_;
if (!(defined $params->{bug_ids} || defined $params->{comment_ids})) {
ThrowCodeError('params_required',
{ function => 'Bug.comments',
params => ['bug_ids', 'comment_ids'] });
}
my $bug_ids = $params->{bug_ids} || [];
my $comment_ids = $params->{comment_ids} || [];
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
my %bugs;
foreach my $bug_id (@$bug_ids) {
my $bug = Bugzilla::Bug->check($bug_id);
# We want the API to always return comments in the same order.
my $comments = Bugzilla::Bug::GetComments(
$bug->id, 'oldest_to_newest', $params->{new_since});
my @result;
foreach my $comment (@$comments) {
next if $comment->{isprivate} && !$user->is_insider;
$comment->{bug_id} = $bug->id;
push(@result, $self->_translate_comment($comment, $params));
}
$bugs{$bug->id}{'comments'} = \@result;
}
my %comments;
if (scalar @$comment_ids) {
my @ids = map { trim($_) } @$comment_ids;
my @sql_ids = map { $dbh->quote($_) } @ids;
my $comment_data = $dbh->selectall_arrayref(
'SELECT comment_id AS id, bug_id, who, bug_when AS time,
isprivate, thetext AS body, type, extra_data
FROM longdescs WHERE ' . $dbh->sql_in('comment_id', \@sql_ids),
{Slice=>{}});
# See if we were passed any invalid comment ids.
my %got_ids = map { $_->{id} => 1 } @$comment_data;
foreach my $comment_id (@ids) {
if (!$got_ids{$comment_id}) {
ThrowUserError('comment_id_invalid', { id => $comment_id });
}
}
# Now make sure that we can see all the associated bugs.
my %got_bug_ids = map { $_->{bug_id} => 1 } @$comment_data;
Bugzilla::Bug->check($_) foreach (keys %got_bug_ids);
foreach my $comment (@$comment_data) {
if ($comment->{isprivate} && !$user->is_insider) {
ThrowUserError('comment_is_private', { id => $comment->{id} });
}
$comment->{author} = new Bugzilla::User($comment->{who});
$comment->{body} = Bugzilla::Bug::format_comment($comment);
$comments{$comment->{id}} =
$self->_translate_comment($comment, $params);
}
}
return { bugs => \%bugs, comments => \%comments };
}
# Helper for Bug.comments
sub _translate_comment {
my ($self, $comment, $filters) = @_;
return filter $filters, {
id => $self->type('int', $comment->{id}),
bug_id => $self->type('int', $comment->{bug_id}),
author => $self->type('string', $comment->{author}->login),
time => $self->type('dateTime', $comment->{'time'}),
is_private => $self->type('boolean', $comment->{isprivate}),
text => $self->type('string', $comment->{body}),
};
}
sub get {
my ($self, $params) = @_;
my $ids = $params->{ids};
defined $ids || ThrowCodeError('param_required', { param => 'ids' });
my @return;
foreach my $bug_id (@$ids) {
my $bug = Bugzilla::Bug->check($bug_id);
# Timetracking fields are deleted if the user doesn't belong to
# the corresponding group.
unless (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) {
delete $bug->{'estimated_time'};
delete $bug->{'remaining_time'};
delete $bug->{'deadline'};
}
# This is done in this fashion in order to produce a stable API.
# The internals of Bugzilla::Bug are not stable enough to just
# return them directly.
my %item;
$item{'creation_time'} = $self->type('dateTime', $bug->creation_ts);
$item{'last_change_time'} = $self->type('dateTime', $bug->delta_ts);
$item{'internals'} = $bug;
$item{'id'} = $self->type('int', $bug->bug_id);
$item{'summary'} = $self->type('string', $bug->short_desc);
$item{'assigned_to'} = $self->type('string', $bug->assigned_to->login );
$item{'resolution'} = $self->type('string', $bug->resolution);
$item{'status'} = $self->type('string', $bug->bug_status);
$item{'is_open'} = $self->type('boolean', $bug->status->is_open);
$item{'severity'} = $self->type('string', $bug->bug_severity);
$item{'priority'} = $self->type('string', $bug->priority);
$item{'product'} = $self->type('string', $bug->product);
$item{'component'} = $self->type('string', $bug->component);
$item{'dupe_of'} = $self->type('int', $bug->dup_id);
# if we do not delete this key, additional user info, including their
# real name, etc, will wind up in the 'internals' hashref
delete $item{internals}->{assigned_to_obj};
if (Bugzilla->params->{'usebugaliases'}) {
$item{'alias'} = $self->type('string', $bug->alias);
}
else {
# For API reasons, we always want the value to appear, we just
# don't want it to have a value if aliases are turned off.
$item{'alias'} = undef;
}
push(@return, \%item);
}
return { bugs => \@return };
}
# this is a function that gets bug activity for list of bug ids
# it can be called as the following:
# $call = $rpc->call( 'Bug.get_history', { ids => [1,2] });
sub get_history {
my ($self, $params) = @_;
my $ids = $params->{ids};
defined $ids || ThrowCodeError('param_required', { param => 'ids' });
my @return;
foreach my $bug_id (@$ids) {
my %item;
my $bug = Bugzilla::Bug->check($bug_id);
$bug_id = $bug->id;
my ($activity) = Bugzilla::Bug::GetBugActivity($bug_id);
$item{$bug_id} = [];
foreach my $changeset (@$activity) {
my %bug_history;
$bug_history{when} = $self->type('dateTime',
$self->datetime_format($changeset->{when}));
$bug_history{who} = $self->type('string', $changeset->{who});
$bug_history{changes} = [];
foreach my $change (@{ $changeset->{changes} }) {
my $attach_id = delete $change->{attachid};
if ($attach_id) {
$change->{attachment_id} = $self->type('int', $attach_id);
}
$change->{removed} = $self->type('string', $change->{removed});
$change->{added} = $self->type('string', $change->{added});
$change->{field_name} = $self->type('string',
delete $change->{fieldname});
# This is going to go away in the future from GetBugActivity
# so we shouldn't put it in the API.
delete $change->{field};
push (@{$bug_history{changes}}, $change);
}
push (@{$item{$bug_id}}, \%bug_history);
}
# alias is returned in case users passes a mixture of ids and aliases
# then they get to know which bug activity relates to which value
# they passed
if (Bugzilla->params->{'usebugaliases'}) {
$item{alias} = $self->type('string', $bug->alias);
}
else {
# For API reasons, we always want the value to appear, we just
# don't want it to have a value if aliases are turned off.
$item{alias} = undef;
}
push(@return, \%item);
}
return { bugs => \@return };
}
sub create {
my ($self, $params) = @_;
Bugzilla->login(LOGIN_REQUIRED);
my %field_values;
foreach my $field (keys %$params) {
my $field_name = FIELD_MAP->{$field} || $field;
$field_values{$field_name} = $params->{$field};
}
# WebService users can't set the creation date of a bug.
delete $field_values{'creation_ts'};
my $bug = Bugzilla::Bug->create(\%field_values);
Bugzilla::BugMail::Send($bug->bug_id, { changer => $bug->reporter->login });
return { id => $self->type('int', $bug->bug_id) };
}
sub legal_values {
my ($self, $params) = @_;
my $field = FIELD_MAP->{$params->{field}} || $params->{field};
my @global_selects = Bugzilla->get_fields(
{type => [FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT]});
my $values;
if (grep($_->name eq $field, @global_selects)) {
$values = get_legal_field_values($field);
}
elsif (grep($_ eq $field, PRODUCT_SPECIFIC_FIELDS)) {
my $id = $params->{product_id};
defined $id || ThrowCodeError('param_required',
{ function => 'Bug.legal_values', param => 'product_id' });
grep($_->id eq $id, @{Bugzilla->user->get_accessible_products})
|| ThrowUserError('product_access_denied', { product => $id });
my $product = new Bugzilla::Product($id);
my @objects;
if ($field eq 'version') {
@objects = @{$product->versions};
}
elsif ($field eq 'target_milestone') {
@objects = @{$product->milestones};
}
elsif ($field eq 'component') {
@objects = @{$product->components};
}
$values = [map { $_->name } @objects];
}
else {
ThrowCodeError('invalid_field_name', { field => $params->{field} });
}
my @result;
foreach my $val (@$values) {
push(@result, $self->type('string', $val));
}
return { values => \@result };
}
sub add_comment {
my ($self, $params) = @_;
#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 $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});
# Append comment
$bug->add_comment($comment, { isprivate => $params->{private},
work_time => $params->{work_time} });
# 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->login });
return { id => $self->type('int', $new_comment_id) };
}
sub update_see_also {
my ($self, $params) = @_;
my $user = Bugzilla->login(LOGIN_REQUIRED);
# Check parameters
$params->{ids}
|| ThrowCodeError('param_required', { param => 'id' });
my ($add, $remove) = @$params{qw(add remove)};
($add || $remove)
or ThrowCodeError('params_required', { params => ['add', 'remove'] });
my @bugs;
foreach my $id (@{ $params->{ids} }) {
my $bug = Bugzilla::Bug->check($id);
$user->can_edit_product($bug->product_id)
|| ThrowUserError("product_edit_denied",
{ product => $bug->product });
push(@bugs, $bug);
if ($remove) {
$bug->remove_see_also($_) foreach @$remove;
}
if ($add) {
$bug->add_see_also($_) foreach @$add;
}
}
my %changes;
foreach my $bug (@bugs) {
my $change = $bug->update();
if (my $see_also = $change->{see_also}) {
$changes{$bug->id} = {
removed => [split(', ', $see_also->[0])],
added => [split(', ', $see_also->[1])],
};
}
else {
# We still want a changes entry, for API consistency.
$changes{$bug->id} = { added => [], removed => [] };
}
Bugzilla::BugMail::Send($bug->id, { changer => $user->login });
}
return { changes => \%changes };
}
1;
__END__
=head1 NAME
Bugzilla::Webservice::Bug - The API for creating, changing, and getting the
details of bugs.
=head1 DESCRIPTION
This part of the Bugzilla API allows you to file a new bug in Bugzilla,
or get information about bugs that have already been filed.
=head1 METHODS
See L<Bugzilla::WebService> for a description of how parameters are passed,
and what B<STABLE>, B<UNSTABLE>, and B<EXPERIMENTAL> mean.
=head2 Utility Functions
=over
=item C<legal_values>
B<EXPERIMENTAL>
=over
=item B<Description>
Tells you what values are allowed for a particular field.
=item B<Params>
=over
=item C<field> - The name of the field you want information about.
This should be the same as the name you would use in L</create>, below.
=item C<product_id> - If you're picking a product-specific field, you have
to specify the id of the product you want the values for.
=back
=item B<Returns>
C<values> - An array of strings: the legal values for this field.
The values will be sorted as they normally would be in Bugzilla.
=item B<Errors>
=over
=item 106 (Invalid Product)
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).
=item 108 (Invalid Field Name)
You specified a field that doesn't exist or isn't a drop-down field.
=back
=back
=back
=head2 Bug Information
=over
=item C<comments>
B<UNSTABLE>
=over
=item B<Description>
This allows you to get data about comments, given a list of bugs
and/or comment ids.
=item B<Params>
B<Note>: At least one of C<bug_ids> or C<comment_ids> is required.
In addition to the parameters below, this method also accepts the
standard L<include_fields|Bugzilla::WebService/include_fields> and
L<exclude_fields|Bugzilla::WebService/exclude_fields> arguments.
=over
=item C<bug_ids>
C<array> An array that can contain both bug IDs and bug aliases.
All of the comments (that are visible to you) will be returned for the
specified bugs.
=item C<comment_ids>
C<array> An array of integer comment_ids. These comments will be
returned individually, separate from any other comments in their
respective bugs.
=item C<new_since>
C<dateTime> If specified, the method will only return comments I<newer>
than this time. This only affects comments returned from the C<bug_ids>
argument. You will always be returned all comments you request in the
C<comment_ids> argument, even if they are older than this date.
=back
=item B<Returns>
Two items are returned:
=over
=item C<bugs>
This is used for bugs specified in C<bug_ids>. This is a hash,
where the keys are the numeric ids of the bugs, and the value is
a hash with a single key, C<comments>, which is an array of comments.
(The format of comments is described below.)
Note that any individual bug will only be returned once, so if you
specify an id multiple times in C<bug_ids>, it will still only be
returned once.
=item C<comments>
Each individual comment requested in C<comment_ids> is returned here,
in a hash where the numeric comment id is the key, and the value
is the comment. (The format of comments is described below.)
=back
A "comment" as described above is a hash that contains the following
keys:
=over
=item id
C<int> The globally unique ID for the comment.
=item bug_id
C<int> The ID of the bug that this comment is on.
=item text
C<string> The actual text of the comment.
=item author
C<string> The login name of the comment's author.
=item time
C<dateTime> The time (in Bugzilla's timezone) that the comment was added.
=item is_private
C<boolean> True if this comment is private (only visible to a certain
group called the "insidergroup"), False otherwise.
=back
=item B<Errors>
This method can throw all the same errors as L</get>. In addition,
it can also throw the following errors:
=over
=item 110 (Comment Is Private)
You specified the id of a private comment in the C<comment_ids>
argument, and you are not in the "insider group" that can see
private comments.
=item 111 (Invalid Comment ID)
You specified an id in the C<comment_ids> argument that is invalid--either
you specified something that wasn't a number, or there is no comment with
that id.
=back
=back
=item C<get>
B<EXPERIMENTAL>
=over
=item B<Description>
Gets information about particular bugs in the database.
Note: Can also be called as "get_bugs" for compatibilty with Bugzilla 3.0 API.
=item B<Params>
=over
=item C<ids>
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.
Note that it's possible for aliases to be disabled in Bugzilla, in which
case you will be told that you have specified an invalid bug_id if you
try to specify an alias. (It will be error 100.)
=back
=item B<Returns>
A hash containing a single element, C<bugs>. This is an array of hashes.
Each hash contains the following items:
=over
=item alias
C<string> The alias of this bug. If there is no alias or aliases are
disabled in this Bugzilla, this will be an empty string.
=item assigned_to
C<string> The login name of the user to whom the bug is assigned.
=item component
C<string> The name of the current component of this bug.
=item creation_time
C<dateTime> When the bug was created.
=item dupe_of
C<int> 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.
=item id
C<int> The numeric bug_id of this bug.
=item internals B<UNSTABLE>
A hash. The internals of a L<Bugzilla::Bug> object. This is extremely
unstable, and you should only rely on this if you absolutely have to. The
structure of the hash may even change between point releases of Bugzilla.
=item is_open
C<boolean> Returns true (1) if this bug is open, false (0) if it is closed.
=item last_change_time
C<dateTime> When the bug was last changed.
=item priority
C<string> The priority of the bug.
=item product
C<string> The name of the product this bug is in.
=item resolution
C<string> The current resolution of the bug, or an empty string if the bug is open.
=item severity
C<string> The current severity of the bug.
=item status
C<string> The current status of the bug.
=item summary
C<string> The summary of this bug.
=back
=item B<Errors>
=over
=item 100 (Invalid Bug Alias)
If you specified an alias and either: (a) the Bugzilla you're querying
doesn't support aliases or (b) there is no bug with that alias.
=item 101 (Invalid Bug ID)
The bug_id you specified doesn't exist in the database.
=item 102 (Access Denied)
You do not have access to the bug_id you specified.
=back
=item B<History>
=over
=item The following properties were added to this method's return value
in Bugzilla B<3.4>:
=over
=item assigned_to
=item component
=item dupe_of
=item is_open
=item priority
=item product
=item resolution
=item severity
=item status
=back
=back
=back
=item C<get_history>
B<UNSTABLE>
=over
=item B<Description>
Gets the history of changes for particular bugs in the database.
=item B<Params>
=over
=item C<ids>
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 data bug
with that alias will be loaded.
Note that it's possible for aliases to be disabled in Bugzilla, in which
case you will be told that you have specified an invalid bug_id if you
try to specify an alias. (It will be error 100.)
=back
=item B<Returns>
A hash containing a single element, C<bugs>. This is a hash of hashes.
Each hash has the numeric bug id as a key, and contains the following
items:
=over
=item alias
C<string> The alias of this bug. If there is no alias or aliases are
disabled in this Bugzilla, this will be undef.
=over
=item when
C<dateTime> The date the bug activity/change happened.
=item who
C<string> The login name of the user who performed the bug change.
=item changes
C<array> An array of hashes which contain all the changes that happened
to the bug at this time (as specified by C<when>). Each hash contains
the following items:
=over
=item field_name
C<string> The name of the bug field that has changed.
=item removed
C<string> The previous value of the bug field which has been deleted
by the change.
=item added
C<string> The new value of the bug field which has been added by the change.
=item attachment_id
C<int> The id of the attachment that was changed. This only appears if
the change was to an attachment, otherwise C<attachment_id> will not be
present in this hash.
=back
=back
=back
=item B<Errors>
The same as L</get>.
=item B<History>
=over
=item Added in Bugzilla B<3.4>.
=back
=back
=back
=head2 Bug Creation and Modification
=over
=item C<create>
B<EXPERIMENTAL>
=over
=item B<Description>
This allows you to create a new bug in Bugzilla. If you specify any
invalid fields, they will be ignored. If you specify any fields you
are not allowed to set, they will just be set to their defaults or ignored.
You cannot currently set all the items here that you can set on enter_bug.cgi.
The WebService interface may allow you to set things other than those listed
here, but realize that anything undocumented is B<UNSTABLE> and will very
likely change in the future.
=item B<Params>
Some params must be set, or an error will be thrown. These params are
marked B<Required>.
Some parameters can have defaults set in Bugzilla, by the administrator.
If these parameters have defaults set, you can omit them. These parameters
are marked B<Defaulted>.
Clients that want to be able to interact uniformly with multiple
Bugzillas should always set both the params marked B<Required> and those
marked B<Defaulted>, because some Bugzillas may not have defaults set
for B<Defaulted> parameters, and then this method will throw an error
if you don't specify them.
The descriptions of the parameters below are what they mean when Bugzilla is
being used to track software bugs. They may have other meanings in some
installations.
=over
=item C<product> (string) B<Required> - The name of the product the bug
is being filed against.
=item C<component> (string) B<Required> - The name of a component in the
product above.
=item C<summary> (string) B<Required> - A brief description of the bug being
filed.
=item C<version> (string) B<Required> - A version of the product above;
the version the bug was found in.
=item C<description> (string) B<Defaulted> - The initial description for
this bug. Some Bugzilla installations require this to not be blank.
=item C<op_sys> (string) B<Defaulted> - The operating system the bug was
discovered on.
=item C<platform> (string) B<Defaulted> - What type of hardware the bug was
experienced on.
=item C<priority> (string) B<Defaulted> - What order the bug will be fixed
in by the developer, compared to the developer's other bugs.
=item C<severity> (string) B<Defaulted> - How severe the bug is.
=item C<alias> (string) - A brief alias for the bug that can be used
instead of a bug number when accessing this bug. Must be unique in
all of this Bugzilla.
=item C<assigned_to> (username) - A user to assign this bug to, if you
don't want it to be assigned to the component owner.
=item C<cc> (array) - An array of usernames to CC on this bug.
=item C<qa_contact> (username) - If this installation has QA Contacts
enabled, you can set the QA Contact here if you don't want to use
the component's default QA Contact.
=item C<status> (string) - The status that this bug should start out as.
Note that only certain statuses can be set on bug creation.
=item C<target_milestone> (string) - A valid target milestone for this
product.
=back
In addition to the above parameters, if your installation has any custom
fields, you can set them just by passing in the name of the field and
its value as a string.
=item B<Returns>
A hash with one element, C<id>. This is the id of the newly-filed bug.
=item B<Errors>
=over
=item 51 (Invalid Object)
The component you specified is not valid for this Product.
=item 103 (Invalid Alias)
The alias you specified is invalid for some reason. See the error message
for more details.
=item 104 (Invalid Field)
One of the drop-down fields has an invalid value, or a value entered in a
text field is too long. The error message will have more detail.
=item 105 (Invalid Component)
You didn't specify a component.
=item 106 (Invalid Product)
Either you didn't specify a product, this product doesn't exist, or
you don't have permission to enter bugs in this product.
=item 107 (Invalid Summary)
You didn't specify a summary for the bug.
=item 504 (Invalid User)
Either the QA Contact, Assignee, or CC lists have some invalid user
in them. The error message will have more details.
=back
=item B<History>
=over
=item Before B<3.0.4>, parameters marked as B<Defaulted> were actually
B<Required>, due to a bug in Bugzilla.
=back
=back
=item C<add_comment>
B<EXPERIMENTAL>
=over
=item B<Description>
This allows you to add a comment to a bug in Bugzilla.
=item B<Params>
=over
=item C<id> (int) B<Required> - The id or alias of the bug to append a
comment to.
=item C<comment> (string) B<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 C<comment> parameter.
=item C<private> (boolean) - If set to true, the comment is private, otherwise
it is assumed to be public.
=item C<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.
=back
=item B<Returns>
A hash with one element, C<id> whose value is the id of the newly-created comment.
=item B<Errors>
=over
=item 100 (Invalid Bug Alias)
If you specified an alias and either: (a) the Bugzilla you're querying
doesn't support aliases or (b) there is no bug with that alias.
=item 101 (Invalid Bug ID)
The id you specified doesn't exist in the database.
=item 108 (Bug Edit Denied)
You did not have the necessary rights to edit the bug.
=back
=item B<History>
=over
=item Added in Bugzilla B<3.2>.
=item Modified to return the new comment's id in Bugzilla B<3.4>
=back
=back
=item C<update_see_also>
B<UNSTABLE>
=over
=item B<Description>
Adds or removes URLs for the "See Also" field on bugs. These URLs must
point to some valid bug in some Bugzilla installation.
=item B<Params>
=over
=item C<ids>
Array of C<int>s or C<string>s. The ids or aliases of bugs that you want
to modify.
=item C<add>
Array of C<string>s. URLs to Bugzilla bugs. These URLs will be added to
the See Also field. They must be valid URLs to C<show_bug.cgi> in a
Bugzilla installation. If they don't start with C<http://> or C<https://>,
it will be assumed that C<http://> should be added to the beginning of the
string.
It is safe to specify URLs that are already in the "See Also" field on
a bug--they will just be silently ignored.
=item C<remove>
Array of C<string>s. 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.
=back
NOTE: If you specify the same URL in both C<add> and C<remove>, it will
be I<added>. (That is, C<add> overrides C<remove>.)
=item B<Returns>
C<changes>, a hash where the keys are numeric bug ids and the contents
are a hash with one key, C<see_also>. C<see_also> points to a hash, which
contains two keys, C<added> and C<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:
{
changes => {
1 => {
added => (an array of bug URLs),
removed => (an array of bug URLs),
},
2 => {
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 C<Bug.update>
method.
=item B<Errors>
This method can throw all of the errors that L</get> throws, plus:
=over
=item 108 (Bug Edit Denied)
You did not have the necessary rights to edit the bug.
=item 112 (Invalid Bug URL)
One of the URLs you provided did not look like a valid bug URL.
=back
=item B<History>
=over
=item Added in Bugzilla B<3.4>.
=back
=back
=back
|