@@ -116,6 +116,7 @@ our %api_field_types = (
116116);
117117
118118our %api_field_names = reverse %{Bugzilla::Bug::FIELD_MAP()};
119+
119120# This doesn't normally belong in FIELD_MAP, but we do want to translate
120121# "bug_group" back into "groups".
121122$api_field_names {' bug_group' } = ' groups' ;
@@ -171,7 +172,7 @@ sub fields {
171172 foreach my $field (@fields ) {
172173 my $visibility_field
173174 = $field -> visibility_field ? $field -> visibility_field-> name : undef ;
174- my $vis_values = $field -> visibility_values;
175+ my $vis_values = $field -> visibility_values;
175176 my $value_field = $field -> value_field ? $field -> value_field-> name : undef ;
176177
177178 my (@values , $has_values );
@@ -180,27 +181,27 @@ sub fields {
180181 or $field -> name eq ' keywords' )
181182 {
182183 $has_values = 1;
183- @values = @{$self -> _legal_field_values({field => $field })};
184+ @values = @{$self -> _legal_field_values({field => $field })};
184185 }
185186
186187 if (grep ($_ eq $field -> name, PRODUCT_SPECIFIC_FIELDS)) {
187188 $value_field = ' product' ;
188189 }
189190
190191 my %field_data = (
191- id => $self -> type(' int' , $field -> id),
192- type => $self -> type(' int' , $field -> type),
193- is_custom => $self -> type(' boolean' , $field -> custom),
194- name => $self -> type(' string' , $field -> name),
195- display_name => $self -> type(' string' , $field -> description),
196- is_mandatory => $self -> type(' boolean' , $field -> is_mandatory),
197- is_on_bug_entry => $self -> type(' boolean' , $field -> enter_bug),
198- visibility_field => $self -> type(' string' , $visibility_field ),
192+ id => $self -> type(' int' , $field -> id),
193+ type => $self -> type(' int' , $field -> type),
194+ is_custom => $self -> type(' boolean' , $field -> custom),
195+ name => $self -> type(' string' , $field -> name),
196+ display_name => $self -> type(' string' , $field -> description),
197+ is_mandatory => $self -> type(' boolean' , $field -> is_mandatory),
198+ is_on_bug_entry => $self -> type(' boolean' , $field -> enter_bug),
199+ visibility_field => $self -> type(' string' , $visibility_field ),
199200 visibility_values => [map { $self -> type(' string' , $_ -> name) } @$vis_values ],
200201 );
201202 if ($has_values ) {
202203 $field_data {value_field } = $self -> type(' string' , $value_field );
203- $field_data {values } = \@values ;
204+ $field_data {values } = \@values ;
204205 }
205206 push (@fields_out , filter $params , \%field_data );
206207 }
@@ -318,8 +319,8 @@ sub comments {
318319 {function => ' Bug.comments' , params => [' ids' , ' comment_ids' ]});
319320 }
320321
321- my $bug_ids = $params -> {ids } || [];
322- my $comment_ids = $params -> {comment_ids } || [];
322+ my $bug_ids = $params -> {ids } || [];
323+ my $comment_ids = $params -> {comment_ids } || [];
323324 my $skip_private = $params -> {skip_private } ? 1 : 0;
324325
325326 my $dbh = Bugzilla-> switch_to_shadow_db();
@@ -330,6 +331,7 @@ sub comments {
330331 }
331332
332333 if ($skip_private ) {
334+
333335 # Cache permissions for bugs. This highly reduces the number of calls to the DB.
334336 # visible_bugs() is only able to handle bug IDs, so we have to skip aliases.
335337 my @int = grep { $_ =~ / ^\d +$ / } @$bug_ids ;
@@ -343,7 +345,8 @@ sub comments {
343345 if ($skip_private ) {
344346 $bug = Bugzilla::Bug-> new({id => $bug_id , cache => 1});
345347 next if $bug -> error || !$user -> can_see_bug($bug -> id);
346- } else {
348+ }
349+ else {
347350 $bug = Bugzilla::Bug-> check($bug_id );
348351 }
349352
@@ -362,7 +365,7 @@ sub comments {
362365
363366 my %comments ;
364367 if (scalar @$comment_ids ) {
365- my @ids = map { trim($_ ) } @$comment_ids ;
368+ my @ids = map { trim($_ ) } @$comment_ids ;
366369 my $comment_data = Bugzilla::Comment-> new_from_list(\@ids );
367370
368371 # See if we were passed any invalid comment ids.
@@ -501,6 +504,7 @@ sub history {
501504 my $skip_private = $params -> {skip_private } ? 1 : 0;
502505
503506 if ($skip_private ) {
507+
504508 # Cache permissions for bugs. This highly reduces the number of calls to the DB.
505509 # visible_bugs() is only able to handle bug IDs, so we have to skip aliases.
506510 my @int = grep { $_ =~ / ^\d +$ / } @$ids ;
@@ -515,7 +519,8 @@ sub history {
515519 if ($skip_private ) {
516520 $bug = Bugzilla::Bug-> new({id => $bug_id , cache => 1});
517521 next if $bug -> error || !$user -> can_see_bug($bug -> id);
518- } else {
522+ }
523+ else {
519524 $bug = Bugzilla::Bug-> check($bug_id );
520525 }
521526
@@ -586,7 +591,7 @@ sub search {
586591
587592 # Allow to search only in bug description (initial comment)
588593 if (defined $match_params -> {description }) {
589- $match_params -> {longdesc } = delete $match_params -> {description };
594+ $match_params -> {longdesc } = delete $match_params -> {description };
590595 $match_params -> {longdesc_initial } = 1;
591596 }
592597
@@ -595,7 +600,7 @@ sub search {
595600 my %options = (fields => [' bug_id' ]);
596601
597602 # Find the highest custom field id
598- my @field_ids = grep (/ ^f(\d +)$ / , keys %$match_params );
603+ my @field_ids = grep (/ ^f(\d +)$ / , keys %$match_params );
599604 my $last_field_id = @field_ids ? max @field_ids + 1 : 1;
600605
601606 # Do special search types for certain fields.
@@ -837,7 +842,7 @@ sub update {
837842
838843 my %changes = %{$all_changes {$bug -> id}};
839844 foreach my $field (keys %changes ) {
840- my $change = $changes {$field };
845+ my $change = $changes {$field };
841846 my $api_field = $api_field_names {$field } || $field ;
842847
843848 # We normalize undef to an empty string, so that the API
@@ -1194,10 +1199,9 @@ sub add_comment {
11941199 $bug -> add_comment(
11951200 $comment ,
11961201 {
1197- isprivate => $params -> {is_private },
1198- work_time => $params -> {work_time },
1199- is_markdown =>
1200- ( defined $params -> {is_markdown } ? $params -> {is_markdown } : 0 )
1202+ isprivate => $params -> {is_private },
1203+ work_time => $params -> {work_time },
1204+ is_markdown => (defined $params -> {is_markdown } ? $params -> {is_markdown } : 0)
12011205 }
12021206 );
12031207
@@ -1481,7 +1485,7 @@ sub _bug_to_hash {
14811485 foreach my $attachment (@{$bug -> attachments}) {
14821486 next if $attachment -> isprivate && !$user -> is_insider;
14831487 push (@result ,
1484- $self -> _attachment_to_hash($attachment , $params , [' extra' ], ' attachments' ));
1488+ $self -> _attachment_to_hash($attachment , $params , [' extra' ], ' attachments' ));
14851489 }
14861490 $item {' attachments' } = \@result ;
14871491 }
@@ -1494,12 +1498,12 @@ sub _bug_to_hash {
14941498 }
14951499 if (filter_wants $params , ' comments' , [' extra' ]) {
14961500 my @result ;
1497- my $comments
1498- = $bug -> comments( {order => ' oldest_to_newest' , after => $params -> {new_since }});
1501+ my $comments = $bug -> comments(
1502+ {order => ' oldest_to_newest' , after => $params -> {new_since }});
14991503 foreach my $comment (@$comments ) {
15001504 next if $comment -> is_private && !$user -> is_insider;
15011505 push (@result ,
1502- $self -> _translate_comment($comment , $params , [' extra' ], ' comments' ));
1506+ $self -> _translate_comment($comment , $params , [' extra' ], ' comments' ));
15031507 }
15041508 $item {' comments' } = \@result ;
15051509 }
@@ -1528,7 +1532,8 @@ sub _bug_to_hash {
15281532 my $comment = Bugzilla::Comment-> match({bug_id => $bug -> id, LIMIT => 1})-> [0];
15291533 $item {' description' }
15301534 = ($comment && (!$comment -> is_private || Bugzilla-> user-> is_insider))
1531- ? $comment -> body : ' ' ;
1535+ ? $comment -> body
1536+ : ' ' ;
15321537 }
15331538 if (filter_wants $params , ' dupe_of' ) {
15341539 $item {' dupe_of' } = $self -> type(' int' , $bug -> dup_id);
@@ -1549,7 +1554,7 @@ sub _bug_to_hash {
15491554 = Bugzilla::Bug::GetBugActivity($bug -> id, undef , $params -> {new_since }, 1);
15501555 foreach my $changeset (@$activity ) {
15511556 push (@result ,
1552- $self -> _changeset_to_hash($changeset , $params , [' extra' ], ' history' ));
1557+ $self -> _changeset_to_hash($changeset , $params , [' extra' ], ' history' ));
15531558 }
15541559 $item {' history' } = \@result ;
15551560 }
@@ -1760,14 +1765,14 @@ sub _changeset_to_hash {
17601765 my $attach_id = delete $change -> {attachid };
17611766 my $comment = delete $change -> {comment };
17621767
1763- $change -> {field_name } = $self -> type(' string' , $api_field_name );
1764- $change -> {removed } = $self -> type($api_field_type , $change -> {removed });
1765- $change -> {added } = $self -> type($api_field_type , $change -> {added });
1768+ $change -> {field_name } = $self -> type(' string' , $api_field_name );
1769+ $change -> {removed } = $self -> type($api_field_type , $change -> {removed });
1770+ $change -> {added } = $self -> type($api_field_type , $change -> {added });
17661771 $change -> {attachment_id } = $self -> type(' int' , $attach_id ) if $attach_id ;
17671772 $change -> {comment_id } = $self -> type(' int' , $comment -> id) if $comment ;
17681773 $change -> {comment_count } = $self -> type(' int' , $comment -> count) if $comment ;
17691774
1770- push (@{$item -> {changes }}, $change );
1775+ push (@{$item -> {changes }}, $change );
17711776 }
17721777
17731778 return filter($filters , $item , $types , $prefix );
0 commit comments