From d71a5955d23688f97f9586afa57f860da97c3831 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Sun, 28 Mar 2010 14:37:28 -0700 Subject: [PATCH] Bug 554569: WebService Bug.fields: Make it so that if you request a field by both id and name, only one field is returned r=dkl, a=mkanat --- Bugzilla/WebService/Bug.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 07a8c7dd35..a249de05d8 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -79,14 +79,16 @@ sub fields { my $names = $params->{names}; foreach my $field_name (@$names) { my $loop_field = Bugzilla::Field->check($field_name); - push(@fields, $loop_field); + # Don't push in duplicate fields if we also asked for this field + # in "ids". + if (!grep($_->id == $loop_field->id, @fields)) { + push(@fields, $loop_field); + } } } - if (!defined $params->{ids} - and !defined $params->{names}) - { - @fields = @{Bugzilla::Field->match({obsolete => 0})}; + if (!defined $params->{ids} and !defined $params->{names}) { + @fields = Bugzilla->get_fields({ obsolete => 0 }); } my @fields_out; -- 2.47.2