Properly close db cursors

This commit is contained in:
Roeland Jago Douma 2015-10-27 10:22:59 +01:00
parent 629bac22fd
commit 17a066c18e
2 changed files with 7 additions and 4 deletions

View File

@ -277,7 +277,7 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
\OCP\Constants::PERMISSION_UPDATE, \OCP\Constants::PERMISSION_UPDATE,
\OCP\Constants::PERMISSION_CREATE, \OCP\Constants::PERMISSION_CREATE,
\OCP\Constants::PERMISSION_SHARE, \OCP\Constants::PERMISSION_SHARE,
\OCP\Constants::PERMISSION_DELETE \OCP\Constants::PERMISSION_DELETE,
]; ];
$allPermissions = $powerset($permissions); $allPermissions = $powerset($permissions);

View File

@ -1123,9 +1123,10 @@ class Share extends Constants {
->from('share') ->from('share')
->where($qb->expr()->eq('id', $qb->createParameter('id'))) ->where($qb->expr()->eq('id', $qb->createParameter('id')))
->setParameter(':id', $rootItem['parent']); ->setParameter(':id', $rootItem['parent']);
$result = $qb->execute(); $dbresult = $qb->execute();
$result = $result->fetch(); $result = $dbresult->fetch();
$dbresult->closeCursor();
if (~(int)$result['permissions'] & $permissions) { if (~(int)$result['permissions'] & $permissions) {
$message = 'Setting permissions for %s failed,' $message = 'Setting permissions for %s failed,'
.' because the permissions exceed permissions granted to %s'; .' because the permissions exceed permissions granted to %s';
@ -1189,6 +1190,7 @@ class Share extends Constants {
$parents[] = $item['id']; $parents[] = $item['id'];
} }
} }
$result->closeCursor();
} }
// Remove the permissions for all reshares of this item // Remove the permissions for all reshares of this item
@ -1209,7 +1211,7 @@ class Share extends Constants {
/* /*
* Permissions were added * Permissions were added
* Update all USERGROUP shares. (So group shares where the user moved his mountpoint). * Update all USERGROUP shares. (So group shares where the user moved their mountpoint).
*/ */
if ($permissions & ~(int)$rootItem['permissions']) { if ($permissions & ~(int)$rootItem['permissions']) {
$qb = $connection->getQueryBuilder(); $qb = $connection->getQueryBuilder();
@ -1229,6 +1231,7 @@ class Share extends Constants {
$items[] = $item; $items[] = $item;
$ids[] = $item['id']; $ids[] = $item['id'];
} }
$result->closeCursor();
// Add permssions for all USERGROUP shares of this item // Add permssions for all USERGROUP shares of this item
if (!empty($ids)) { if (!empty($ids)) {