diff options
author | Simon Green <sgreen@redhat.com> | 2013-03-25 15:47:56 +0100 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2013-03-25 15:47:56 +0100 |
commit | 64a789e7629fa8b20f68267245d7fe79dd14d41a (patch) | |
tree | 4fef3b5a6c615f9f78b300df2a7f01954b229607 /Bugzilla/WebService | |
parent | ba88aea7c2824dc612add370e836a1fedd5740d4 (diff) | |
download | bugzilla-64a789e7629fa8b20f68267245d7fe79dd14d41a.tar.gz bugzilla-64a789e7629fa8b20f68267245d7fe79dd14d41a.tar.xz |
Bug 838846 - In Product.get, include_fields => ['components'] no longer returns data about components
Diffstat (limited to 'Bugzilla/WebService')
-rw-r--r-- | Bugzilla/WebService/Product.pm | 21 | ||||
-rw-r--r-- | Bugzilla/WebService/Util.pm | 17 |
2 files changed, 26 insertions, 12 deletions
diff --git a/Bugzilla/WebService/Product.pm b/Bugzilla/WebService/Product.pm index 7d31f2c38..525339cda 100644 --- a/Bugzilla/WebService/Product.pm +++ b/Bugzilla/WebService/Product.pm @@ -153,20 +153,20 @@ sub _product_to_hash { } if (filter_wants($params, 'versions')) { $field_data->{versions} = [map { - $self->_version_to_hash($_) + $self->_version_to_hash($_, $params) } @{$product->versions}]; } if (filter_wants($params, 'milestones')) { $field_data->{milestones} = [map { - $self->_milestone_to_hash($_) + $self->_milestone_to_hash($_, $params) } @{$product->milestones}]; } return filter($params, $field_data); } sub _component_to_hash { - my ($self, $component) = @_; - return { + my ($self, $component, $params) = @_; + my $field_data = { id => $self->type('int', $component->id), name => @@ -182,11 +182,12 @@ sub _component_to_hash { is_active => $self->type('boolean', $component->is_active), }; + return filter($params, $field_data, 'components'); } sub _version_to_hash { - my ($self, $version) = @_; - return { + my ($self, $version, $params) = @_; + my $field_data = { id => $self->type('int', $version->id), name => @@ -196,11 +197,12 @@ sub _version_to_hash { is_active => $self->type('boolean', $version->is_active), }; + return filter($params, $field_data, 'versions'); } sub _milestone_to_hash { - my ($self, $milestone) = @_; - return { + my ($self, $milestone, $params) = @_; + my $field_data = { id => $self->type('int', $milestone->id), name => @@ -210,6 +212,7 @@ sub _milestone_to_hash { is_active => $self->type('boolean', $milestone->is_active), }; + return filter($params, $field_data, 'milestones'); } 1; @@ -315,6 +318,8 @@ 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. +This RPC call supports sub field restrictions. + =over =item C<ids> diff --git a/Bugzilla/WebService/Util.pm b/Bugzilla/WebService/Util.pm index dbf670bf7..193dab92d 100644 --- a/Bugzilla/WebService/Util.pm +++ b/Bugzilla/WebService/Util.pm @@ -52,11 +52,20 @@ sub filter_wants ($$;$) { $field = "${prefix}.${field}" if $prefix; - if (defined $params->{include_fields}) { - return 0 if !$include{$field}; + if (defined $params->{exclude_fields} && $exclude{$field}) { + return 0; } - if (defined $params->{exclude_fields}) { - return 0 if $exclude{$field}; + if (defined $params->{include_fields} && !$include{$field}) { + if ($prefix) { + # Include the field if the parent is include (and this one is not excluded) + return 0 if !$include{$prefix}; + } + else { + # We want to include this if one of the sub keys is included + my $key = $field . '.'; + my $len = length($key); + return 0 if ! grep { substr($_, 0, $len) eq $key } keys %include; + } } return 1; |