From 7ff15c975694f838a21e8e40cc03e21da83fdf97 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 9 Oct 2019 19:13:27 +0200 Subject: fix documentation, get and createGroup may return null * also have stricter checks in place Signed-off-by: Arthur Schiwon --- core/Command/Group/Add.php | 4 ++++ core/Command/User/Add.php | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'core/Command') 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('Could not create group'); + 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() . '"'); } } } -- cgit v1.2.3