Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
75f87ced
Commit
75f87ced
authored
Jul 31, 2012
by
Frank Becker
Committed by
Dave Lawrence
Jul 31, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 775056 - Add prefix to filter() and filter_wants()
r=dkl, a=LpSolit
parent
47126598
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
Util.pm
Bugzilla/WebService/Util.pm
+14
-5
No files found.
Bugzilla/WebService/Util.pm
View file @
75f87ced
...
...
@@ -22,22 +22,24 @@ our @EXPORT_OK = qw(
params_to_objects
)
;
sub
filter
($$)
{
my
(
$params
,
$hash
)
=
@_
;
sub
filter
($$
;$
) {
my
(
$params
,
$hash
,
$prefix
)
=
@_
;
my
%
newhash
=
%
$hash
;
foreach
my
$key
(
keys
%
$hash
)
{
delete
$newhash
{
$key
}
if
!
filter_wants
(
$params
,
$key
);
delete
$newhash
{
$key
}
if
!
filter_wants
(
$params
,
$key
,
$prefix
);
}
return
\%
newhash
;
}
sub
filter_wants
($$)
{
my
(
$params
,
$field
)
=
@_
;
sub
filter_wants
($$
;$
) {
my
(
$params
,
$field
,
$prefix
)
=
@_
;
my
%
include
=
map
{
$_
=>
1
}
@
{
$params
->
{
'include_fields'
}
||
[]
};
my
%
exclude
=
map
{
$_
=>
1
}
@
{
$params
->
{
'exclude_fields'
}
||
[]
};
$field
=
"${prefix}.${field}"
if
$prefix
;
if
(
defined
$params
->
{
include_fields
})
{
return
0
if
!
$include
{
$field
};
}
...
...
@@ -150,6 +152,13 @@ of WebService methods. Given a hash (the second argument to this subroutine),
this will remove any keys that are I<not> in C<include_fields> and then remove
any keys that I<are> in C<exclude_fields>.
An optional third option can be passed that prefixes the field name to allow
filtering of data two or more levels deep.
For example, if you want to filter out the C<id> key/value in components returned
by Product.get, you would use the value C<component.id> in your C<exclude_fields>
list.
=head2 filter_wants
Returns C<1> if a filter would preserve the specified field when passing
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment