Skip to content

Commit

Permalink
ENH get cached Member in SessionManagerField (#151)
Browse files Browse the repository at this point in the history
calling ->Member on distinct object is never going to trigger ORM cache. Since the member is expected to be always the same, this leads to duplicate queries

Co-authored-by: Michal Kleiner <[email protected]>
  • Loading branch information
lekoala and michalkleiner authored Jul 4, 2023
1 parent c5ca5eb commit c7a59f2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/FormFields/SessionManagerField.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,16 @@ protected function getLoginSessions(Member $member)
if (!$loginSession->canView()) {
continue;
}


$loginSessions[] = [
'ID' => $loginSession->ID,
'IPAddress' => $loginSession->IPAddress,
'UserAgent' => $loginSession->getFriendlyUserAgent(),
'IsCurrent' => $loginSession->isCurrent(),
'Persistent' => $loginSession->Persistent,
'Member' => [
'Name' => $loginSession->Member()->Name
'Name' => Member::get_by_id($loginSession->MemberID)->Name ?? ''
],
'Created' => $this->addUtcOffset($loginSession->Created),
'LastAccessed' => $this->addUtcOffset($loginSession->LastAccessed),
Expand Down

0 comments on commit c7a59f2

Please sign in to comment.