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
6f4b2629
Commit
6f4b2629
authored
Apr 16, 2014
by
Byron Jones
Committed by
David Lawrence
Apr 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 993894 - the database query in bless_groups is slow
r=dkl,a=justdave
parent
e93a383f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
22 deletions
+30
-22
User.pm
Bugzilla/User.pm
+30
-22
No files found.
Bugzilla/User.pm
View file @
6f4b2629
...
...
@@ -765,34 +765,42 @@ sub bless_groups {
return
$self
->
{
'bless_groups'
};
}
if
(
Bugzilla
->
params
->
{
usevisibilitygroups
}
&&
!
$self
->
visible_groups_inherited
)
{
return
[]
;
}
my
$dbh
=
Bugzilla
->
dbh
;
# Get all groups for the user where:
# + They have direct bless privileges
# + They are a member of a group that inherits bless privs.
my
@group_ids
=
map
{
$_
->
id
}
@
{
$self
->
groups
};
@group_ids
=
(
-
1
)
if
!
@group_ids
;
my
$query
=
'SELECT DISTINCT groups.id
FROM groups, user_group_map, group_group_map AS ggm
WHERE user_group_map.user_id = ?
AND ( (user_group_map.isbless = 1
AND groups.id=user_group_map.group_id)
OR (groups.id = ggm.grantor_id
AND ggm.grant_type = '
.
GROUP_BLESS
.
'
AND '
.
$dbh
->
sql_in
(
'ggm.member_id'
,
\
@group_ids
)
.
') )'
;
# If visibilitygroups are used, restrict the set of groups.
if
(
Bugzilla
->
params
->
{
'usevisibilitygroups'
})
{
return
[]
if
!
$self
->
visible_groups_as_string
;
# Users need to see a group in order to bless it.
# Get all groups for the user where they have direct bless privileges.
my
$query
=
"
SELECT DISTINCT group_id
FROM user_group_map
WHERE user_id = ?
AND isbless = 1"
;
if
(
Bugzilla
->
params
->
{
usevisibilitygroups
})
{
$query
.=
" AND "
.
$dbh
->
sql_in
(
'groups.id'
,
$self
->
visible_groups_inherited
);
.
$dbh
->
sql_in
(
'group_id'
,
$self
->
visible_groups_inherited
);
}
# Get all groups for the user where they are a member of a group that
# inherits bless privs.
my
@group_ids
=
map
{
$_
->
id
}
@
{
$self
->
groups
};
if
(
@group_ids
)
{
$query
.=
"
UNION
SELECT DISTINCT grantor_id
FROM group_group_map
WHERE grant_type = "
.
GROUP_BLESS
.
"
AND "
.
$dbh
->
sql_in
(
'member_id'
,
\
@group_ids
);
if
(
Bugzilla
->
params
->
{
usevisibilitygroups
})
{
$query
.=
" AND "
.
$dbh
->
sql_in
(
'grantor_id'
,
$self
->
visible_groups_inherited
);
}
}
my
$ids
=
$dbh
->
selectcol_arrayref
(
$query
,
undef
,
$self
->
id
);
return
$self
->
{
'bless_groups'
}
=
Bugzilla::
Group
->
new_from_list
(
$ids
);
return
$self
->
{
bless_groups
}
=
Bugzilla::
Group
->
new_from_list
(
$ids
);
}
sub
in_group
{
...
...
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