perf: Make fetching user details lazy

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2023-02-15 13:11:33 +01:00
parent ea8b7999f7
commit 81c0d96357
7 changed files with 40 additions and 33 deletions

View File

@@ -455,13 +455,11 @@ class BoardMapper extends QBMapper implements IPermissionMapper {
}
public function mapAcl(Acl &$acl) {
$userManager = $this->userManager;
$groupManager = $this->groupManager;
$acl->resolveRelation('participant', function ($participant) use (&$acl, &$userManager, &$groupManager) {
if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
$user = $userManager->get($participant);
if ($user !== null) {
return new User($user);
if ($this->userManager->userExists($acl->getParticipant())) {
return new User($acl->getParticipant(), $this->userManager);
}
$this->logger->debug('User ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
return null;
@@ -499,9 +497,8 @@ class BoardMapper extends QBMapper implements IPermissionMapper {
public function mapOwner(Board &$board) {
$userManager = $this->userManager;
$board->resolveRelation('owner', function ($owner) use (&$userManager) {
$user = $userManager->get($owner);
if ($user !== null) {
return new User($user);
if ($this->userManager->userExists($owner)) {
return new User($owner, $userManager);
}
return null;
});