From 07fe1df8c1165bb3338be5864bc8fb0289e024a6 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 28 Oct 2015 09:09:16 +0100 Subject: Make \OC\SubAdmin php-5.4 compatible * Also close some cursors while we are at it --- lib/private/subadmin.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'lib/private/subadmin.php') 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; } /** -- cgit v1.2.3