Skip to content

Commit

Permalink
[BUGFIX] Fix return type of findByUid()
Browse files Browse the repository at this point in the history
On access restricted pages an exception is thrown as  the user is null. (If logged in via backend)
  • Loading branch information
BastiLu committed Jan 30, 2025
1 parent b23b0cb commit 158df4e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Classes/Domain/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ public function findByUsergroup(int $uid): QueryResultInterface
* @param int $uid
* @return User
*/
public function findByUid($uid): User
public function findByUid($uid): ?User
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->matching($query->equals('uid', $uid));
/** @var User $user */
$user = $query->execute()->getFirst();
return $user;
/** @var User|null $user */
return $query->execute()->getFirst();

Check failure on line 41 in Classes/Domain/Repository/UserRepository.php

View workflow job for this annotation

GitHub Actions / PHPstan

Method In2code\Powermail\Domain\Repository\UserRepository::findByUid() should return In2code\Powermail\Domain\Model\User|null but returns TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface|null.

Check failure on line 41 in Classes/Domain/Repository/UserRepository.php

View workflow job for this annotation

GitHub Actions / PHPstan

Variable $user in PHPDoc tag @var does not exist.
}

/**
Expand Down

0 comments on commit 158df4e

Please sign in to comment.