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
74954fdd
Commit
74954fdd
authored
Jul 26, 2013
by
Simon Green
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 880093 - Cache filter_wants
r=glob, a=glob
parent
8afeaf6d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
Util.pm
Bugzilla/WebService/Util.pm
+17
-7
No files found.
Bugzilla/WebService/Util.pm
View file @
74954fdd
...
...
@@ -38,28 +38,38 @@ sub filter ($$;$) {
sub
filter_wants
($$;$) {
my
(
$params
,
$field
,
$prefix
)
=
@_
;
my
%
include
=
map
{
$_
=>
1
}
@
{
$params
->
{
'include_fields'
}
||
[]
};
my
%
exclude
=
map
{
$_
=>
1
}
@
{
$params
->
{
'exclude_fields'
}
||
[]
};
# Since this is operation is resource intensive, we will cache the results
# This assumes that $params->{*_fields} doesn't change between calls
my
$cache
=
Bugzilla
->
request_cache
->
{
filter_wants
}
||=
{};
$field
=
"${prefix}.${field}"
if
$prefix
;
if
(
exists
$cache
->
{
$field
})
{
return
$cache
->
{
$field
};
}
my
%
include
=
map
{
$_
=>
1
}
@
{
$params
->
{
'include_fields'
}
||
[]
};
my
%
exclude
=
map
{
$_
=>
1
}
@
{
$params
->
{
'exclude_fields'
}
||
[]
};
my
$wants
=
1
;
if
(
defined
$params
->
{
exclude_fields
}
&&
$exclude
{
$field
})
{
return
0
;
$wants
=
0
;
}
if
(
defined
$params
->
{
include_fields
}
&&
!
$include
{
$field
})
{
els
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
};
$wants
=
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
;
$wants
=
0
if
!
grep
{
substr
(
$_
,
0
,
$len
)
eq
$key
}
keys
%
include
;
}
}
return
1
;
$cache
->
{
$field
}
=
$wants
;
return
$wants
;
}
sub
taint_data
{
...
...
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