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:
Thomas Portelange 2016-09-15 16:45:40 +02:00 committed by Daniel Hensby
parent 8c23b67b9f
commit 995d07756d

View File

@ -837,8 +837,9 @@ class Member extends DataObject implements TemplateGlobalProvider {
$id = Member::currentUserID();
if($id) {
return Member::get()->byId($id);
return DataObject::get_by_id('Member', $id);
}
return null;
}
/**