From 6463e47b80e29c2c9a8e6b9671fe94331a39cf0f Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Sun, 28 Mar 2010 14:36:11 -0700 Subject: 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 934c08e15..240eee91e 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; -- cgit v1.2.3-24-g4f1b