diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2021-03-02 19:34:20 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2021-03-03 14:52:47 +0100 |
commit | 68ec18323d07e7293fd59c82d51300a6d9d68176 (patch) | |
tree | f8b2094b663d481dda920d1df8f9c852fa42ee36 /lib/private | |
parent | 252d2d39583c7daf838a6a24d0f72660ed01c371 (diff) | |
download | nextcloud-server-68ec18323d07e7293fd59c82d51300a6d9d68176.tar.gz nextcloud-server-68ec18323d07e7293fd59c82d51300a6d9d68176.zip |
Fix types in the Group Manager
Psalm found an issue. However the issue found was because of lying
docblocks. Fixed those and did some typing to make it all better.
For #25839
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 4 | ||||
-rw-r--r-- | lib/private/Group/Manager.php | 10 | ||||
-rw-r--r-- | lib/private/Template/JSConfigHelper.php | 4 |
3 files changed, 10 insertions, 8 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 3ef816f503e..7395be703d3 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -234,6 +234,8 @@ class DIContainer extends SimpleContainer implements IAppContainer { ) ); + + $securityMiddleware = new SecurityMiddleware( $c->get(IRequest::class), $c->get(IControllerMethodReflector::class), @@ -242,7 +244,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $server->query(ILogger::class), $c->get('AppName'), $server->getUserSession()->isLoggedIn(), - $server->getGroupManager()->isAdmin($this->getUserId()), + $this->getUserId() !== null && $server->getGroupManager()->isAdmin($this->getUserId()), $server->getUserSession()->getUser() !== null && $server->query(ISubAdmin::class)->isSubAdmin($server->getUserSession()->getUser()), $server->getAppManager(), $server->getL10N('lib') diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index 4c731a9f488..145b3631206 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -276,7 +276,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @param string $uid the user id * @return \OC\Group\Group[] */ - public function getUserIdGroups($uid) { + public function getUserIdGroups(string $uid): array { $groups = []; foreach ($this->getUserIdGroupIds($uid) as $groupId) { @@ -321,17 +321,17 @@ class Manager extends PublicEmitter implements IGroupManager { * get a list of group ids for a user * * @param IUser $user - * @return array with group ids + * @return string[] with group ids */ - public function getUserGroupIds(IUser $user) { + public function getUserGroupIds(IUser $user): array { return $this->getUserIdGroupIds($user->getUID()); } /** * @param string $uid the user id - * @return GroupInterface[] + * @return string[] */ - private function getUserIdGroupIds($uid) { + private function getUserIdGroupIds(string $uid): array { if (!isset($this->cachedUserGroups[$uid])) { $groups = []; foreach ($this->backends as $backend) { diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index b228cae6ffb..cd466575601 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -167,7 +167,7 @@ class JSConfigHelper { $countOfDataLocation = 0; $dataLocation = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); - if ($countOfDataLocation !== 1 || !$this->groupManager->isAdmin($uid)) { + if ($countOfDataLocation !== 1 || $uid === null || !$this->groupManager->isAdmin($uid)) { $dataLocation = false; } @@ -198,7 +198,7 @@ class JSConfigHelper { $array = [ "_oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', - "_oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false', + "_oc_isadmin" => $uid !== null && $this->groupManager->isAdmin($uid) ? 'true' : 'false', "backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false', "oc_dataURL" => is_string($dataLocation) ? "\"" . $dataLocation . "\"" : 'false', "_oc_webroot" => "\"" . \OC::$WEBROOT . "\"", |