mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
cache currentUser query (#6007)
* cache currentUser query Various modules can call a lot of time Member::currentUser(). We can avoid querying the database multiple times. Cache is implemented as a static array inside the method and store the data byID, in case the currentUserID changes within the same request (not very likely, but..)
This commit is contained in:
parent
8c23b67b9f
commit
995d07756d
@ -837,8 +837,9 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
$id = Member::currentUserID();
|
$id = Member::currentUserID();
|
||||||
|
|
||||||
if($id) {
|
if($id) {
|
||||||
return Member::get()->byId($id);
|
return DataObject::get_by_id('Member', $id);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user