);
our %api_field_names = reverse %{Bugzilla::Bug::FIELD_MAP()};
+
# This doesn't normally belong in FIELD_MAP, but we do want to translate
# "bug_group" back into "groups".
$api_field_names{'bug_group'} = 'groups';
foreach my $field (@fields) {
my $visibility_field
= $field->visibility_field ? $field->visibility_field->name : undef;
- my $vis_values = $field->visibility_values;
+ my $vis_values = $field->visibility_values;
my $value_field = $field->value_field ? $field->value_field->name : undef;
my (@values, $has_values);
or $field->name eq 'keywords')
{
$has_values = 1;
- @values = @{$self->_legal_field_values({field => $field})};
+ @values = @{$self->_legal_field_values({field => $field})};
}
if (grep($_ eq $field->name, PRODUCT_SPECIFIC_FIELDS)) {
}
my %field_data = (
- id => $self->type('int', $field->id),
- type => $self->type('int', $field->type),
- is_custom => $self->type('boolean', $field->custom),
- name => $self->type('string', $field->name),
- display_name => $self->type('string', $field->description),
- is_mandatory => $self->type('boolean', $field->is_mandatory),
- is_on_bug_entry => $self->type('boolean', $field->enter_bug),
- visibility_field => $self->type('string', $visibility_field),
+ id => $self->type('int', $field->id),
+ type => $self->type('int', $field->type),
+ is_custom => $self->type('boolean', $field->custom),
+ name => $self->type('string', $field->name),
+ display_name => $self->type('string', $field->description),
+ is_mandatory => $self->type('boolean', $field->is_mandatory),
+ is_on_bug_entry => $self->type('boolean', $field->enter_bug),
+ visibility_field => $self->type('string', $visibility_field),
visibility_values => [map { $self->type('string', $_->name) } @$vis_values],
);
if ($has_values) {
$field_data{value_field} = $self->type('string', $value_field);
- $field_data{values} = \@values;
+ $field_data{values} = \@values;
}
push(@fields_out, filter $params, \%field_data);
}
{function => 'Bug.comments', params => ['ids', 'comment_ids']});
}
- my $bug_ids = $params->{ids} || [];
- my $comment_ids = $params->{comment_ids} || [];
+ my $bug_ids = $params->{ids} || [];
+ my $comment_ids = $params->{comment_ids} || [];
my $skip_private = $params->{skip_private} ? 1 : 0;
my $dbh = Bugzilla->switch_to_shadow_db();
}
if ($skip_private) {
+
# Cache permissions for bugs. This highly reduces the number of calls to the DB.
# visible_bugs() is only able to handle bug IDs, so we have to skip aliases.
my @int = grep { $_ =~ /^\d+$/ } @$bug_ids;
if ($skip_private) {
$bug = Bugzilla::Bug->new({id => $bug_id, cache => 1});
next if $bug->error || !$user->can_see_bug($bug->id);
- } else {
+ }
+ else {
$bug = Bugzilla::Bug->check($bug_id);
}
my %comments;
if (scalar @$comment_ids) {
- my @ids = map { trim($_) } @$comment_ids;
+ my @ids = map { trim($_) } @$comment_ids;
my $comment_data = Bugzilla::Comment->new_from_list(\@ids);
# See if we were passed any invalid comment ids.
my $skip_private = $params->{skip_private} ? 1 : 0;
if ($skip_private) {
+
# Cache permissions for bugs. This highly reduces the number of calls to the DB.
# visible_bugs() is only able to handle bug IDs, so we have to skip aliases.
my @int = grep { $_ =~ /^\d+$/ } @$ids;
if ($skip_private) {
$bug = Bugzilla::Bug->new({id => $bug_id, cache => 1});
next if $bug->error || !$user->can_see_bug($bug->id);
- } else {
+ }
+ else {
$bug = Bugzilla::Bug->check($bug_id);
}
# Allow to search only in bug description (initial comment)
if (defined $match_params->{description}) {
- $match_params->{longdesc} = delete $match_params->{description};
+ $match_params->{longdesc} = delete $match_params->{description};
$match_params->{longdesc_initial} = 1;
}
my %options = (fields => ['bug_id']);
# Find the highest custom field id
- my @field_ids = grep(/^f(\d+)$/, keys %$match_params);
+ my @field_ids = grep(/^f(\d+)$/, keys %$match_params);
my $last_field_id = @field_ids ? max @field_ids + 1 : 1;
# Do special search types for certain fields.
my %changes = %{$all_changes{$bug->id}};
foreach my $field (keys %changes) {
- my $change = $changes{$field};
+ my $change = $changes{$field};
my $api_field = $api_field_names{$field} || $field;
# We normalize undef to an empty string, so that the API
$bug->add_comment(
$comment,
{
- isprivate => $params->{is_private},
- work_time => $params->{work_time},
- is_markdown =>
- ( defined $params->{is_markdown} ? $params->{is_markdown} : 0 )
+ isprivate => $params->{is_private},
+ work_time => $params->{work_time},
+ is_markdown => (defined $params->{is_markdown} ? $params->{is_markdown} : 0)
}
);
foreach my $attachment (@{$bug->attachments}) {
next if $attachment->isprivate && !$user->is_insider;
push(@result,
- $self->_attachment_to_hash($attachment, $params, ['extra'], 'attachments'));
+ $self->_attachment_to_hash($attachment, $params, ['extra'], 'attachments'));
}
$item{'attachments'} = \@result;
}
}
if (filter_wants $params, 'comments', ['extra']) {
my @result;
- my $comments
- = $bug->comments({order => 'oldest_to_newest', after => $params->{new_since}});
+ my $comments = $bug->comments(
+ {order => 'oldest_to_newest', after => $params->{new_since}});
foreach my $comment (@$comments) {
next if $comment->is_private && !$user->is_insider;
push(@result,
- $self->_translate_comment($comment, $params, ['extra'], 'comments'));
+ $self->_translate_comment($comment, $params, ['extra'], 'comments'));
}
$item{'comments'} = \@result;
}
my $comment = Bugzilla::Comment->match({bug_id => $bug->id, LIMIT => 1})->[0];
$item{'description'}
= ($comment && (!$comment->is_private || Bugzilla->user->is_insider))
- ? $comment->body : '';
+ ? $comment->body
+ : '';
}
if (filter_wants $params, 'dupe_of') {
$item{'dupe_of'} = $self->type('int', $bug->dup_id);
= Bugzilla::Bug::GetBugActivity($bug->id, undef, $params->{new_since}, 1);
foreach my $changeset (@$activity) {
push(@result,
- $self->_changeset_to_hash($changeset, $params, ['extra'], 'history'));
+ $self->_changeset_to_hash($changeset, $params, ['extra'], 'history'));
}
$item{'history'} = \@result;
}
my $attach_id = delete $change->{attachid};
my $comment = delete $change->{comment};
- $change->{field_name} = $self->type('string', $api_field_name);
- $change->{removed} = $self->type($api_field_type, $change->{removed});
- $change->{added} = $self->type($api_field_type, $change->{added});
+ $change->{field_name} = $self->type('string', $api_field_name);
+ $change->{removed} = $self->type($api_field_type, $change->{removed});
+ $change->{added} = $self->type($api_field_type, $change->{added});
$change->{attachment_id} = $self->type('int', $attach_id) if $attach_id;
$change->{comment_id} = $self->type('int', $comment->id) if $comment;
$change->{comment_count} = $self->type('int', $comment->count) if $comment;
- push (@{$item->{changes}}, $change);
+ push(@{$item->{changes}}, $change);
}
return filter($filters, $item, $types, $prefix);