summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/Command/Group/Add.php4
-rw-r--r--core/Command/User/Add.php11
-rw-r--r--lib/private/Group/Manager.php8
-rw-r--r--lib/private/Setup.php5
-rw-r--r--lib/public/IGroupManager.php4
5 files changed, 22 insertions, 10 deletions
diff --git a/core/Command/Group/Add.php b/core/Command/Group/Add.php
index f2ee6195a44..284cf7a3e9d 100644
--- a/core/Command/Group/Add.php
+++ b/core/Command/Group/Add.php
@@ -68,6 +68,10 @@ class Add extends Base {
return 1;
} else {
$group = $this->groupManager->createGroup($gid);
+ if($group === false) {
+ $output->writeln('<error>Could not create group</error>');
+ return 2;
+ }
$output->writeln('Created group "' . $group->getGID() . '"');
$displayName = trim((string) $input->getOption('display-name'));
diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php
index cc53f1c78c0..c66b5eb819c 100644
--- a/core/Command/User/Add.php
+++ b/core/Command/User/Add.php
@@ -25,6 +25,7 @@
namespace OC\Core\Command\User;
use OC\Files\Filesystem;
+use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
@@ -152,10 +153,14 @@ class Add extends Command {
if (!$group) {
$this->groupManager->createGroup($groupName);
$group = $this->groupManager->get($groupName);
- $output->writeln('Created group "' . $group->getGID() . '"');
+ if($group instanceof IGroup) {
+ $output->writeln('Created group "' . $group->getGID() . '"');
+ }
+ }
+ if($group instanceof IGroup) {
+ $group->addUser($user);
+ $output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
}
- $group->addUser($user);
- $output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
}
}
}
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);