diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-10-28 09:09:16 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2015-10-28 09:09:16 +0100 |
commit | 07fe1df8c1165bb3338be5864bc8fb0289e024a6 (patch) | |
tree | 675021044a4a9e2be641b98a071488fec026d065 /lib/private/subadmin.php | |
parent | 588a668455536a576bfe0b42ef61806dfeab61bc (diff) | |
download | nextcloud-server-07fe1df8c1165bb3338be5864bc8fb0289e024a6.tar.gz nextcloud-server-07fe1df8c1165bb3338be5864bc8fb0289e024a6.zip |
Make \OC\SubAdmin php-5.4 compatible
* Also close some cursors while we are at it
Diffstat (limited to 'lib/private/subadmin.php')
-rw-r--r-- | lib/private/subadmin.php | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/private/subadmin.php b/lib/private/subadmin.php index e1a7644f0f8..6bf960661b5 100644 --- a/lib/private/subadmin.php +++ b/lib/private/subadmin.php @@ -116,6 +116,7 @@ class SubAdmin extends PublicEmitter { while($row = $result->fetch()) { $groups[] = $this->groupManager->get($row['gid']); } + $result->closeCursor(); return $groups; } @@ -137,6 +138,7 @@ class SubAdmin extends PublicEmitter { while($row = $result->fetch()) { $users[] = $this->userManager->get($row['uid']); } + $result->closeCursor(); return $users; } @@ -159,6 +161,8 @@ class SubAdmin extends PublicEmitter { 'group' => $this->groupManager->get($row['gid']) ]; } + $result->closeCursor(); + return $subadmins; } @@ -171,13 +175,20 @@ class SubAdmin extends PublicEmitter { public function isSubAdminofGroup(IUser $user, IGroup $group) { $qb = $this->dbConn->getQueryBuilder(); + /* + * Primary key is ('gid', 'uid') so max 1 result possible here + */ $result = $qb->select('*') ->from('group_admin') ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID()))) ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID()))) ->execute(); - return !empty($result->fetch()) ? true : false; + $fetch = $result->fetch(); + $result->closeCursor(); + $result = !empty($fetch) ? true : false; + + return $result; } /** @@ -197,10 +208,14 @@ class SubAdmin extends PublicEmitter { ->from('group_admin') ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID()))) ->setMaxResults(1) - ->execute() - ->fetch(); + ->execute(); + + $isSubAdmin = $result->fetch(); + $result->closeCursor(); + + $result = $isSubAdmin === false ? false : true; - return $result === false ? false : true; + return $result; } /** |