summaryrefslogtreecommitdiffstats
path: root/lib/private/Group/Manager.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Group/Manager.php')
-rw-r--r--lib/private/Group/Manager.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php
index 944598a8296..40009dbfd80 100644
--- a/lib/private/Group/Manager.php
+++ b/lib/private/Group/Manager.php
@@ -37,7 +37,10 @@ namespace OC\Group;
use OC\Hooks\PublicEmitter;
use OCP\GroupInterface;
+use OCP\IGroup;
use OCP\IGroupManager;
+use OCP\ILogger;
+use OCP\IUser;
/**
* Class Manager
@@ -78,11 +81,16 @@ class Manager extends PublicEmitter implements IGroupManager {
/** @var \OC\SubAdmin */
private $subAdmin = null;
+ /** @var ILogger */
+ private $logger;
+
/**
* @param \OC\User\Manager $userManager
+ * @param ILogger $logger
*/
- public function __construct(\OC\User\Manager $userManager) {
+ public function __construct(\OC\User\Manager $userManager, ILogger $logger) {
$this->userManager = $userManager;
+ $this->logger = $logger;
$cachedGroups = & $this->cachedGroups;
$cachedUserGroups = & $this->cachedUserGroups;
$this->listen('\OC\Group', 'postDelete', function ($group) use (&$cachedGroups, &$cachedUserGroups) {
@@ -186,7 +194,7 @@ class Manager extends PublicEmitter implements IGroupManager {
* @return bool
*/
public function groupExists($gid) {
- return !is_null($this->get($gid));
+ return $this->get($gid) instanceof IGroup;
}
/**
@@ -194,7 +202,7 @@ class Manager extends PublicEmitter implements IGroupManager {
* @return \OC\Group\Group
*/
public function createGroup($gid) {
- if ($gid === '' || is_null($gid)) {
+ if ($gid === '' || $gid === null) {
return false;
} else if ($group = $this->get($gid)) {
return $group;
@@ -223,7 +231,12 @@ class Manager extends PublicEmitter implements IGroupManager {
foreach ($this->backends as $backend) {
$groupIds = $backend->getGroups($search, $limit, $offset);
foreach ($groupIds as $groupId) {
- $groups[$groupId] = $this->get($groupId);
+ $aGroup = $this->get($groupId);
+ if ($aGroup instanceof IGroup) {
+ $groups[$groupId] = $aGroup;
+ } else {
+ $this->logger->debug('Group "' . $groupId . '" was returned by search but not found through direct access', ['app' => 'core']);
+ }
}
if (!is_null($limit) and $limit <= 0) {
return array_values($groups);
@@ -237,7 +250,7 @@ class Manager extends PublicEmitter implements IGroupManager {
* @return \OC\Group\Group[]
*/
public function getUserGroups($user) {
- if (is_null($user)) {
+ if (!$user instanceof IUser) {
return [];
}
return $this->getUserIdGroups($user->getUID());
@@ -256,7 +269,12 @@ class Manager extends PublicEmitter implements IGroupManager {
$groupIds = $backend->getUserGroups($uid);
if (is_array($groupIds)) {
foreach ($groupIds as $groupId) {
- $groups[$groupId] = $this->get($groupId);
+ $aGroup = $this->get($groupId);
+ if ($aGroup instanceof IGroup) {
+ $groups[$groupId] = $aGroup;
+ } else {
+ $this->logger->debug('User "' . $uid . '" belongs to deleted group: "' . $groupId . '"', ['app' => 'core']);
+ }
}
}
}