Skip to content

Commit 158df4e

Browse files
committed
[BUGFIX] Fix return type of findByUid()
On access restricted pages an exception is thrown as the user is null. (If logged in via backend)
1 parent b23b0cb commit 158df4e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Classes/Domain/Repository/UserRepository.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ public function findByUsergroup(int $uid): QueryResultInterface
3232
* @param int $uid
3333
* @return User
3434
*/
35-
public function findByUid($uid): User
35+
public function findByUid($uid): ?User
3636
{
3737
$query = $this->createQuery();
3838
$query->getQuerySettings()->setRespectStoragePage(false);
3939
$query->matching($query->equals('uid', $uid));
40-
/** @var User $user */
41-
$user = $query->execute()->getFirst();
42-
return $user;
40+
/** @var User|null $user */
41+
return $query->execute()->getFirst();
4342
}
4443

4544
/**

0 commit comments

Comments
 (0)