Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
229
Merge Requests
229
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
17329b16
Commit
17329b16
authored
Sep 28, 2011
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#6463
by msonnabaum, Garrett Albright, xjm: Add static caching for user_roles().
parent
094f2704
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
modules/user/user.module
modules/user/user.module
+16
-0
No files found.
modules/user/user.module
View file @
17329b16
...
...
@@ -2739,6 +2739,17 @@ function user_mail_tokens(&$replacements, $data, $options) {
* value.
*/
function
user_roles
(
$membersonly
=
FALSE
,
$permission
=
NULL
)
{
$user_roles
=
&
drupal_static
(
__FUNCTION__
);
// Do not cache roles for specific permissions. This data is not requested
// frequently enough to justify the additional memory use.
if
(
empty
(
$permission
))
{
$cid
=
$membersonly
?
DRUPAL_AUTHENTICATED_RID
:
DRUPAL_ANONYMOUS_RID
;
if
(
isset
(
$user_roles
[
$cid
]))
{
return
$user_roles
[
$cid
];
}
}
$query
=
db_select
(
'role'
,
'r'
);
$query
->
addTag
(
'translatable'
);
$query
->
fields
(
'r'
,
array
(
'rid'
,
'name'
));
...
...
@@ -2767,6 +2778,11 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
}
}
if
(
empty
(
$permission
))
{
$user_roles
[
$cid
]
=
$roles
;
return
$user_roles
[
$cid
];
}
return
$roles
;
}
...
...
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