diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-10-09 19:13:27 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-11-25 14:01:25 +0100 |
commit | 7ff15c975694f838a21e8e40cc03e21da83fdf97 (patch) | |
tree | 365ab9a9a63837693602e6a50d82542e6bd20494 /lib | |
parent | 7b1eedb11e5f55d563831d8e58c44e615267669c (diff) | |
download | nextcloud-server-7ff15c975694f838a21e8e40cc03e21da83fdf97.tar.gz nextcloud-server-7ff15c975694f838a21e8e40cc03e21da83fdf97.zip |
fix documentation, get and createGroup may return null
* also have stricter checks in place
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Group/Manager.php | 8 | ||||
-rw-r--r-- | lib/private/Setup.php | 5 | ||||
-rw-r--r-- | lib/public/IGroupManager.php | 4 |
3 files changed, 10 insertions, 7 deletions
diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index b372eb1786e..9ae25be27f5 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -163,7 +163,7 @@ class Manager extends PublicEmitter implements IGroupManager { /** * @param string $gid - * @return \OC\Group\Group + * @return IGroup|null */ public function get($gid) { if (isset($this->cachedGroups[$gid])) { @@ -175,7 +175,7 @@ class Manager extends PublicEmitter implements IGroupManager { /** * @param string $gid * @param string $displayName - * @return \OCP\IGroup + * @return \OCP\IGroup|null */ protected function getGroupObject($gid, $displayName = null) { $backends = []; @@ -210,11 +210,11 @@ class Manager extends PublicEmitter implements IGroupManager { /** * @param string $gid - * @return IGroup|bool|null + * @return IGroup|null */ public function createGroup($gid) { if ($gid === '' || $gid === null) { - return false; + return null; } else if ($group = $this->get($gid)) { return $group; } else { diff --git a/lib/private/Setup.php b/lib/private/Setup.php index d7c6df3535a..a23ce2dbb0e 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -50,6 +50,7 @@ use OC\Authentication\Token\DefaultTokenProvider; use OC\Log\Rotate; use OC\Preview\BackgroundCleanupJob; use OCP\Defaults; +use OCP\IGroup; use OCP\IL10N; use OCP\ILogger; use OCP\IUser; @@ -380,7 +381,9 @@ class Setup { $config->setAppValue('core', 'vendor', $this->getVendor()); $group =\OC::$server->getGroupManager()->createGroup('admin'); - $group->addUser($user); + if($group instanceof IGroup) { + $group->addUser($user); + } // Install shipped apps and specified app bundles Installer::installShippedApps(); diff --git a/lib/public/IGroupManager.php b/lib/public/IGroupManager.php index f7a63dfefb7..d8a557777bc 100644 --- a/lib/public/IGroupManager.php +++ b/lib/public/IGroupManager.php @@ -75,7 +75,7 @@ interface IGroupManager { /** * @param string $gid - * @return \OCP\IGroup + * @return \OCP\IGroup|null * @since 8.0.0 */ public function get($gid); @@ -89,7 +89,7 @@ interface IGroupManager { /** * @param string $gid - * @return \OCP\IGroup + * @return \OCP\IGroup|null * @since 8.0.0 */ public function createGroup($gid); |