]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't leave cursors open when tests fail 24033/head
authorJoas Schilling <coding@schilljs.com>
Thu, 5 Nov 2020 09:50:53 +0000 (10:50 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 10 Nov 2020 14:18:02 +0000 (14:18 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
36 files changed:
apps/dav/lib/CalDAV/CalDavBackend.php
apps/dav/lib/CardDAV/CardDavBackend.php
apps/dav/lib/Migration/BuildCalendarSearchIndex.php
apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php
apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
apps/federatedfilesharing/lib/FederatedShareProvider.php
apps/federation/lib/DbHandler.php
apps/federation/tests/DbHandlerTest.php
apps/files_external/lib/Service/DBConfigService.php
apps/files_external/tests/Service/StoragesServiceTest.php
apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
apps/files_trashbin/lib/Trashbin.php
apps/files_trashbin/tests/Command/CleanUpTest.php
apps/sharebymail/tests/ShareByMailProviderTest.php
lib/private/Files/Cache/Cache.php
lib/private/Files/Cache/HomeCache.php
lib/private/Files/Cache/StorageGlobal.php
lib/private/Files/Config/UserMountCache.php
lib/private/Files/Node/Folder.php
lib/private/Files/Type/Loader.php
lib/private/Security/CredentialsManager.php
lib/private/Share/Share.php
lib/private/TagManager.php
lib/private/Tags.php
lib/private/legacy/OC_DB_StatementWrapper.php
lib/private/legacy/OC_Util.php
tests/lib/Accounts/AccountsManagerTest.php
tests/lib/DB/ConnectionTest.php
tests/lib/DB/LegacyDBTest.php
tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
tests/lib/Files/Cache/QuerySearchHelperTest.php
tests/lib/Files/Type/LoaderTest.php
tests/lib/Lock/DBLockingProviderTest.php

index 82c14086833bf5cfeefda9fa8be0ff8eb2bf68cd..3115ceea47801deee0596954e50916acc5c5e7d2 100644 (file)
@@ -248,7 +248,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
                        $query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
                }
 
-               return (int)$query->execute()->fetchColumn();
+               $result = $query->execute();
+               $column = (int)$result->fetchColumn();
+               $result->closeCursor();
+               return $column;
        }
 
        /**
@@ -2346,7 +2349,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
                $query->select('synctoken')
                        ->from($table)
                        ->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)));
-               $syncToken = (int)$query->execute()->fetchColumn();
+               $result = $query->execute();
+               $syncToken = (int)$result->fetchColumn();
+               $result->closeCursor();
 
                $query = $this->db->getQueryBuilder();
                $query->insert('calendarchanges')
index 14ade3f16e2188839282b81ea614ce823a6403b2..d517e212c3b263dd98c33348b2670e23e5562e29 100644 (file)
@@ -138,7 +138,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        ->from('addressbooks')
                        ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
 
-               return (int)$query->execute()->fetchColumn();
+               $result = $query->execute();
+               $column = (int) $result->fetchColumn();
+               $result->closeCursor();
+               return $column;
        }
 
        /**
index d16873fee20eb8e59b441f06acff027765ed41eb..117cef7d7bfd1b7c2e4652ab7f2038f22cd2eabd 100644 (file)
@@ -75,7 +75,9 @@ class BuildCalendarSearchIndex implements IRepairStep {
                $query = $this->db->getQueryBuilder();
                $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')'))
                        ->from('calendarobjects');
-               $maxId = (int)$query->execute()->fetchColumn();
+               $result = $query->execute();
+               $maxId = (int) $result->fetchColumn();
+               $result->closeCursor();
 
                $output->info('Add background job');
                $this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [
index 2aef1617df8f50801125e9980c467bee2ded7f86..58e798f42c99f6a9c948e2373a97efc68d2527d5 100644 (file)
@@ -86,7 +86,9 @@ class RegisterBuildReminderIndexBackgroundJob implements IRepairStep {
                $query = $this->db->getQueryBuilder();
                $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')'))
                        ->from('calendarobjects');
-               $maxId = (int)$query->execute()->fetchColumn();
+               $result = $query->execute();
+               $maxId = (int) $result->fetchColumn();
+               $result->closeCursor();
 
                $output->info('Add background job');
                $this->jobList->add(BuildReminderIndexBackgroundJob::class, [
index 95617001b3188118ad80979da4df98c22437339d..abcec14fb7305a2e27982c23832713ad97b059f7 100644 (file)
@@ -549,7 +549,12 @@ class CardDavBackendTest extends TestCase {
                $this->invokePrivate($backend, 'updateProperties', [$bookId, $cardUri, $vCard->serialize()]);
 
                $query = $this->db->getQueryBuilder();
-               $result = $query->select('*')->from('cards_properties')->execute()->fetchAll();
+               $query->select('*')
+                       ->from('cards_properties');
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
 
                $this->assertSame(2, count($result));
 
@@ -569,7 +574,12 @@ class CardDavBackendTest extends TestCase {
                $this->invokePrivate($backend, 'updateProperties', [$bookId, $cardUri, $vCard->serialize()]);
 
                $query = $this->db->getQueryBuilder();
-               $result = $query->select('*')->from('cards_properties')->execute()->fetchAll();
+               $query->select('*')
+                       ->from('cards_properties');
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
 
                $this->assertSame(1, count($result));
 
@@ -609,7 +619,13 @@ class CardDavBackendTest extends TestCase {
                $this->invokePrivate($this->backend, 'purgeProperties', [1, 1]);
 
                $query = $this->db->getQueryBuilder();
-               $result = $query->select('*')->from('cards_properties')->execute()->fetchAll();
+               $query->select('*')
+                       ->from('cards_properties');
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
+
                $this->assertSame(1, count($result));
                $this->assertSame(1 ,(int)$result[0]['addressbookid']);
                $this->assertSame(2 ,(int)$result[0]['cardid']);
index 3e22193fcbfd620812501e80d18b2c289a92e3a9..2633ccf544fe0142b6597f7809fd28dc6d8c5697 100644 (file)
@@ -109,7 +109,12 @@ class CustomPropertiesBackendTest extends TestCase {
                        ->from('properties')
                        ->where($query->expr()->eq('userid', $query->createNamedParameter($user)))
                        ->where($query->expr()->eq('propertypath', $query->createNamedParameter($this->formatPath($path))));
-               return $query->execute()->fetchAll(\PDO::FETCH_KEY_PAIR);
+
+
+               $result = $query->execute();
+               $data = $result->fetchAll(\PDO::FETCH_KEY_PAIR);
+               $result->closeCursor();
+               return $data;
        }
 
        public function testPropFindNoDbCalls() {
index f68ec0278194526c2e0a05a45e87fee6c687ef0d..2e2f0d8adbe941ffc6b651e023443d6b4f6d9bef 100644 (file)
@@ -347,7 +347,9 @@ class FederatedShareProvider implements IShareProvider {
                $query->select('*')->from($this->externalShareTable)
                        ->where($query->expr()->eq('user', $query->createNamedParameter($share->getShareOwner())))
                        ->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget())));
-               $result = $query->execute()->fetchAll();
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
 
                if (isset($result[0]) && (int)$result[0]['remote_id'] > 0) {
                        return $result[0];
@@ -483,7 +485,9 @@ class FederatedShareProvider implements IShareProvider {
                $query = $this->dbConnection->getQueryBuilder();
                $query->select('remote_id')->from('federated_reshares')
                        ->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId())));
-               $data = $query->execute()->fetch();
+               $result = $query->execute();
+               $data = $result->fetch();
+               $result->closeCursor();
 
                if (!is_array($data) || !isset($data['remote_id'])) {
                        throw new ShareNotFound();
index 365a70e2b74be6e30c5e264d92c5e59bd2178860..ef961e90d32f0b885e69b3b126199caac68b220b 100644 (file)
@@ -120,8 +120,10 @@ class DbHandler {
                $query->select('*')->from($this->dbTable)
                        ->where($query->expr()->eq('id', $query->createParameter('id')))
                        ->setParameter('id', $id);
-               $query->execute();
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
 
                if (empty($result)) {
                        throw new \Exception('No Server found with ID: ' . $id);
index 7a06b2c9daade40e85a2ae08ad034a4cae411e12..ee972458747b1756ce5f5638abefc7b51f5d8db3 100644 (file)
@@ -62,7 +62,10 @@ class DbHandlerTest extends TestCase {
                );
 
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertEmpty($result, 'we need to start with a empty trusted_servers table');
        }
 
@@ -83,7 +86,10 @@ class DbHandlerTest extends TestCase {
                $id = $this->dbHandler->addServer($url);
 
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(1, count($result));
                $this->assertSame($expectedUrl, $result[0]['url']);
                $this->assertSame($id, (int)$result[0]['id']);
@@ -104,7 +110,10 @@ class DbHandlerTest extends TestCase {
                $id2 = $this->dbHandler->addServer('server2');
 
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(2, count($result));
                $this->assertSame('server1', $result[0]['url']);
                $this->assertSame('server2', $result[1]['url']);
@@ -113,7 +122,10 @@ class DbHandlerTest extends TestCase {
 
                $this->dbHandler->removeServer($id2);
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(1, count($result));
                $this->assertSame('server1', $result[0]['url']);
                $this->assertSame($id1, (int)$result[0]['id']);
@@ -165,12 +177,18 @@ class DbHandlerTest extends TestCase {
        public function XtestAddToken() {
                $this->dbHandler->addServer('server1');
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(1, count($result));
                $this->assertSame(null, $result[0]['token']);
                $this->dbHandler->addToken('http://server1', 'token');
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(1, count($result));
                $this->assertSame('token', $result[0]['token']);
        }
@@ -186,12 +204,18 @@ class DbHandlerTest extends TestCase {
        public function XtestAddSharedSecret() {
                $this->dbHandler->addServer('server1');
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(1, count($result));
                $this->assertSame(null, $result[0]['shared_secret']);
                $this->dbHandler->addSharedSecret('http://server1', 'secret');
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(1, count($result));
                $this->assertSame('secret', $result[0]['shared_secret']);
        }
@@ -207,12 +231,18 @@ class DbHandlerTest extends TestCase {
        public function testSetServerStatus() {
                $this->dbHandler->addServer('server1');
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(1, count($result));
                $this->assertSame(TrustedServers::STATUS_PENDING, (int)$result[0]['status']);
                $this->dbHandler->setServerStatus('http://server1', TrustedServers::STATUS_OK);
                $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                $this->assertSame(1, count($result));
                $this->assertSame(TrustedServers::STATUS_OK, (int)$result[0]['status']);
        }
index eaa5815cd30ee64bfd42ba9dc18aa90ac3a1d297..f6ccda9561f14d3145ab00c8a3bbdd926fb9540f 100644 (file)
@@ -452,7 +452,10 @@ class DBConfigService {
                $query = $builder->select($fields)
                        ->from($table)
                        ->where($builder->expr()->in('mount_id', $placeHolders));
-               $rows = $query->execute()->fetchAll();
+
+               $result = $query->execute();
+               $rows = $result->fetchAll();
+               $result->closeCursor();
 
                $result = [];
                foreach ($mountIds as $mountId) {
index 5f10a9b9498757f1657c9f56b3efd186ce30530e..b1118a571402a7eacd15b588b4760d545340f453 100644 (file)
@@ -334,7 +334,10 @@ abstract class StoragesServiceTest extends \Test\TestCase {
                $storageCheckQuery = $qb->select('*')
                        ->from('storages')
                        ->where($qb->expr()->eq('numeric_id', $qb->expr()->literal($numericId)));
-               $storages = $storageCheckQuery->execute()->fetchAll();
+
+               $result = $storageCheckQuery->execute();
+               $storages = $result->fetchAll();
+               $result->closeCursor();
                $this->assertCount($expectedCountAfterDeletion, $storages, "expected $expectedCountAfterDeletion storages, got " . json_encode($storages));
        }
 
index dd03ffc66681100984b528ac9d9a86fbe4b501d8..b163583bf11d61e7bd763c34604efe0724eab319 100644 (file)
@@ -142,7 +142,10 @@ class CleanupRemoteStoragesTest extends TestCase {
                $qb->select('*')
                        ->from('storages')
                        ->where($qb->expr()->eq('numeric_id', $qb->createNamedParameter($numericId)));
-               $result = $qb->execute()->fetchAll();
+
+               $qResult = $qb->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                if (!empty($result)) {
                        return true;
                }
@@ -151,7 +154,10 @@ class CleanupRemoteStoragesTest extends TestCase {
                $qb->select('*')
                        ->from('filecache')
                        ->where($qb->expr()->eq('storage', $qb->createNamedParameter($numericId)));
-               $result = $qb->execute()->fetchAll();
+
+               $qResult = $qb->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
                if (!empty($result)) {
                        return true;
                }
index 05cb34ac506da880a0a4d2cf82802c3b3ce90eee..a0e8720d17cbf308f508834d3333d380cad788ce 100644 (file)
@@ -107,7 +107,9 @@ class SetPasswordColumnTest extends TestCase {
                $query = $this->connection->getQueryBuilder();
                $query->select('*')
                        ->from('share');
-               $allShares = $query->execute()->fetchAll();
+               $result = $query->execute();
+               $allShares = $result->fetchAll();
+               $result->closeCursor();
 
                foreach ($allShares as $share) {
                        if ((int)$share['share_type'] === IShare::TYPE_LINK) {
index d0ad7eb9135d9f18937cca3d39eb90aee8efdc94..7f83cbbc8a51c1a4ee2fd0ca0647e774445657d0 100644 (file)
@@ -994,10 +994,14 @@ class Trashbin {
                        ->andWhere($query->expr()->eq('parent', $query->createNamedParameter($parentId)))
                        ->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern)));
 
+               $result = $query->execute();
+               $entries = $result->fetchAll();
+               $result->closeCursor();
+
                /** @var CacheEntry[] $matches */
                $matches = array_map(function (array $data) {
                        return Cache::cacheEntryFromData($data, \OC::$server->getMimeTypeLoader());
-               }, $query->execute()->fetchAll());
+               }, $entries);
 
                foreach ($matches as $ma) {
                        if ($timestamp) {
index 2984645777bca0175632b39e874cf1114dac82ed..f5a89be0e3a8da7241be0b0f149e7b3f6e6e4bc0 100644 (file)
@@ -124,9 +124,13 @@ class CleanUpTest extends TestCase {
                        // if the delete operation was execute only files from user1
                        // should be left.
                        $query = $this->dbConnection->getQueryBuilder();
-                       $result = $query->select('user')
-                               ->from($this->trashTable)
-                               ->execute()->fetchAll();
+                       $query->select('user')
+                               ->from($this->trashTable);
+
+                       $qResult = $query->execute();
+                       $result = $qResult->fetchAll();
+                       $qResult->closeCursor();
+
                        $this->assertSame(5, count($result));
                        foreach ($result as $r) {
                                $this->assertSame('user1', $r['user']);
index 991d5dc021d31539866f7505f956d7e43e886f77..f3e8c60fbf24f90f380fa38f88c67cfc429e9cdd 100644 (file)
@@ -545,10 +545,13 @@ class ShareByMailProviderTest extends TestCase {
                );
 
                $qb = $this->connection->getQueryBuilder();
-               $result = $qb->select('*')
+               $qb->select('*')
                        ->from('share')
-                       ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
-                       ->execute()->fetchAll();
+                       ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
+
+               $qResult = $qb->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
 
                $this->assertSame(1, count($result));
 
@@ -590,10 +593,13 @@ class ShareByMailProviderTest extends TestCase {
                );
 
                $qb = $this->connection->getQueryBuilder();
-               $result = $qb->select('*')
+               $qb->select('*')
                        ->from('share')
-                       ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
-                       ->execute()->fetchAll();
+                       ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
+
+               $qResult = $qb->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
 
                $this->assertSame(1, count($result));
 
@@ -831,7 +837,10 @@ class ShareByMailProviderTest extends TestCase {
                $query = $this->connection->getQueryBuilder();
                $query->select('*')->from('share')
                        ->where($query->expr()->eq('id', $query->createNamedParameter($id)));
-               $before = $query->execute()->fetchAll();
+
+               $result = $query->execute();
+               $before = $result->fetchAll();
+               $result->closeCursor();
 
                $this->assertTrue(is_array($before));
                $this->assertSame(1, count($before));
@@ -841,7 +850,10 @@ class ShareByMailProviderTest extends TestCase {
                $query = $this->connection->getQueryBuilder();
                $query->select('*')->from('share')
                        ->where($query->expr()->eq('id', $query->createNamedParameter($id)));
-               $after = $query->execute()->fetchAll();
+
+               $result = $query->execute();
+               $after = $result->fetchAll();
+               $result->closeCursor();
 
                $this->assertTrue(is_array($after));
                $this->assertEmpty($after);
@@ -861,7 +873,10 @@ class ShareByMailProviderTest extends TestCase {
 
                $query = $this->connection->getQueryBuilder();
                $query->select('*')->from('share');
-               $before = $query->execute()->fetchAll();
+
+               $result = $query->execute();
+               $before = $result->fetchAll();
+               $result->closeCursor();
 
                $this->assertTrue(is_array($before));
                $this->assertSame(2, count($before));
@@ -873,7 +888,10 @@ class ShareByMailProviderTest extends TestCase {
 
                $query = $this->connection->getQueryBuilder();
                $query->select('*')->from('share');
-               $after = $query->execute()->fetchAll();
+
+               $result = $query->execute();
+               $after = $result->fetchAll();
+               $result->closeCursor();
 
                $this->assertTrue(is_array($after));
                $this->assertSame(1, count($after));
index 8a173f351970af2e253a49340a72740651c19ff7..e74cc86d9c9cdaf1158b7c91f526769ef43f7041 100644 (file)
@@ -151,7 +151,9 @@ class Cache implements ICache {
                        $query->whereFileId($file);
                }
 
-               $data = $query->execute()->fetch();
+               $result = $query->execute();
+               $data = $result->fetch();
+               $result->closeCursor();
 
                //merge partial data
                if (!$data and is_string($file) and isset($this->partial[$file])) {
@@ -220,7 +222,10 @@ class Cache implements ICache {
                                ->whereParent($fileId)
                                ->orderBy('name', 'ASC');
 
-                       $files = $query->execute()->fetchAll();
+                       $result = $query->execute();
+                       $files = $result->fetchAll();
+                       $result->closeCursor();
+
                        return array_map(function (array $data) {
                                return self::cacheEntryFromData($data, $this->mimetypeLoader);
                        }, $files);
@@ -467,7 +472,10 @@ class Cache implements ICache {
                        ->whereStorageId()
                        ->wherePath($file);
 
-               $id = $query->execute()->fetchColumn();
+               $result = $query->execute();
+               $id = $result->fetchColumn();
+               $result->closeCursor();
+
                return $id === false ? -1 : (int)$id;
        }
 
@@ -710,7 +718,11 @@ class Cache implements ICache {
                        ->from('filecache')
                        ->whereStorageId()
                        ->wherePath($file);
-               $size = $query->execute()->fetchColumn();
+
+               $result = $query->execute();
+               $size = $result->fetchColumn();
+               $result->closeCursor();
+
                if ($size !== false) {
                        if ((int)$size === -1) {
                                return self::SHALLOW;
@@ -745,9 +757,13 @@ class Cache implements ICache {
                        ->whereStorageId()
                        ->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern)));
 
+               $result = $query->execute();
+               $files = $result->fetchAll();
+               $result->closeCursor();
+
                return array_map(function (array $data) {
                        return self::cacheEntryFromData($data, $this->mimetypeLoader);
-               }, $query->execute()->fetchAll());
+               }, $files);
        }
 
        /**
@@ -782,9 +798,13 @@ class Cache implements ICache {
                        $query->andWhere($query->expr()->eq('mimepart', $query->createNamedParameter($mimeId, IQueryBuilder::PARAM_INT)));
                }
 
+               $result = $query->execute();
+               $files = $result->fetchAll();
+               $result->closeCursor();
+
                return array_map(function (array $data) {
                        return self::cacheEntryFromData($data, $this->mimetypeLoader);
-               }, $query->execute()->fetchAll());
+               }, $files);
        }
 
        public function searchQuery(ISearchQuery $searchQuery) {
@@ -865,7 +885,11 @@ class Cache implements ICache {
                                ->whereParent($fileId)
                                ->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)));
 
-                       return (int)$query->execute()->fetchColumn();
+                       $result = $query->execute();
+                       $size = (int)$result->fetchColumn();
+                       $result->closeCursor();
+
+                       return $size;
                }
                return -1;
        }
@@ -892,7 +916,11 @@ class Cache implements ICache {
                                ->whereStorageId()
                                ->whereParent($id);
 
-                       if ($row = $query->execute()->fetch()) {
+                       $result = $query->execute();
+                       $row = $result->fetch();
+                       $result->closeCursor();
+
+                       if ($row) {
                                [$sum, $min] = array_values($row);
                                $sum = 0 + $sum;
                                $min = 0 + $min;
@@ -920,9 +948,13 @@ class Cache implements ICache {
                        ->from('filecache')
                        ->whereStorageId();
 
+               $result = $query->execute();
+               $files = $result->fetchAll(\PDO::FETCH_COLUMN);
+               $result->closeCursor();
+
                return array_map(function ($id) {
                        return (int)$id;
-               }, $query->execute()->fetchAll(\PDO::FETCH_COLUMN));
+               }, $files);
        }
 
        /**
@@ -942,7 +974,11 @@ class Cache implements ICache {
                        ->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
                        ->orderBy('fileid', 'DESC');
 
-               return $query->execute()->fetchColumn();
+               $result = $query->execute();
+               $path = $result->fetchColumn();
+               $result->closeCursor();
+
+               return $path;
        }
 
        /**
@@ -958,7 +994,10 @@ class Cache implements ICache {
                        ->whereStorageId()
                        ->whereFileId($id);
 
-               $path = $query->execute()->fetchColumn();
+               $result = $query->execute();
+               $path = $result->fetchColumn();
+               $result->closeCursor();
+
                return $path === false ? null : $path;
        }
 
@@ -976,7 +1015,12 @@ class Cache implements ICache {
                $query->select('path', 'storage')
                        ->from('filecache')
                        ->where($query->expr()->eq('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
-               if ($row = $query->execute()->fetch()) {
+
+               $result = $query->execute();
+               $row = $result->fetch();
+               $result->closeCursor();
+
+               if ($row) {
                        $numericId = $row['storage'];
                        $path = $row['path'];
                } else {
index e66ed7d972298133d2eee6b10316b40bc44ef775..f7fc806456d35165821794134fce23989f84cc70 100644 (file)
@@ -72,6 +72,7 @@ class HomeCache extends Cache {
                                        $this->update($id, ['size' => $totalSize]);
                                }
                        }
+                       $result->closeCursor();
                }
                return $totalSize;
        }
index 26a7be24634398f9306f0293de86d929e2184310..8bf37514b8b3f64b8d29e11c93dd902cee15ed40 100644 (file)
@@ -61,6 +61,7 @@ class StorageGlobal {
                while ($row = $result->fetch()) {
                        $this->cache[$row['id']] = $row;
                }
+               $result->closeCursor();
        }
 
        /**
@@ -74,7 +75,10 @@ class StorageGlobal {
                                ->from('storages')
                                ->where($builder->expr()->eq('id', $builder->createNamedParameter($storageId)));
 
-                       $row = $query->execute()->fetch();
+                       $result = $query->execute();
+                       $row = $result->fetch();
+                       $result->closeCursor();
+
                        if ($row) {
                                $this->cache[$storageId] = $row;
                        }
index 6fa9cd96bfe3e52c8ad88d2f9d7f8cb8158250ca..441a4a453260eb4bde6aa384938badbffe87296a 100644 (file)
@@ -235,7 +235,9 @@ class UserMountCache implements IUserMountCache {
                                ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
                                ->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID())));
 
-                       $rows = $query->execute()->fetchAll();
+                       $result = $query->execute();
+                       $rows = $result->fetchAll();
+                       $result->closeCursor();
 
                        $this->mountsForUsers[$user->getUID()] = array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
                }
@@ -258,7 +260,9 @@ class UserMountCache implements IUserMountCache {
                        $query->andWhere($builder->expr()->eq('user_id', $builder->createPositionalParameter($user)));
                }
 
-               $rows = $query->execute()->fetchAll();
+               $result = $query->execute();
+               $rows = $result->fetchAll();
+               $result->closeCursor();
 
                return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
        }
@@ -274,7 +278,9 @@ class UserMountCache implements IUserMountCache {
                        ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
                        ->where($builder->expr()->eq('root_id', $builder->createPositionalParameter($rootFileId, IQueryBuilder::PARAM_INT)));
 
-               $rows = $query->execute()->fetchAll();
+               $result = $query->execute();
+               $rows = $result->fetchAll();
+               $result->closeCursor();
 
                return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
        }
@@ -291,7 +297,10 @@ class UserMountCache implements IUserMountCache {
                                ->from('filecache')
                                ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
 
-                       $row = $query->execute()->fetch();
+                       $result = $query->execute();
+                       $row = $result->fetch();
+                       $result->closeCursor();
+
                        if (is_array($row)) {
                                $this->cacheInfoCache[$fileId] = [
                                        (int)$row['storage'],
index 668893f6549bdb268aff65a02d00de2d969c6fa7..134455dd94521f13196b0dedf2fad03fb0053f45 100644 (file)
@@ -528,7 +528,11 @@ class Folder extends Node implements \OCP\Files\Folder {
                        ->setMaxResults($limit)
                        ->setFirstResult($offset);
 
-               return $query->execute()->fetchAll();
+               $result = $query->execute();
+               $rows = $result->fetchAll();
+               $result->closeCursor();
+
+               return $rows;
        }
 
        private function recentParse($result, $mountMap, $mimetypeLoader) {
index d128bc724b610910dfb28f5616f9dd527d1b037d..489ed65c228034119bf850cfdc5c2e2ab7594365 100644 (file)
@@ -123,7 +123,10 @@ class Loader implements IMimeTypeLoader {
                        ->where(
                                $fetch->expr()->eq('mimetype', $fetch->createNamedParameter($mimetype)
                        ));
-               $row = $fetch->execute()->fetch();
+
+               $result = $fetch->execute();
+               $row = $result->fetch();
+               $result->closeCursor();
 
                if (!$row) {
                        throw new \Exception("Failed to get mimetype id for $mimetype after trying to store it");
@@ -141,7 +144,10 @@ class Loader implements IMimeTypeLoader {
                $qb = $this->dbConnection->getQueryBuilder();
                $qb->select('id', 'mimetype')
                        ->from('mimetypes');
-               $results = $qb->execute()->fetchAll();
+
+               $result = $qb->execute();
+               $results = $result->fetchAll();
+               $result->closeCursor();
 
                foreach ($results as $row) {
                        $this->mimetypes[$row['id']] = $row['mimetype'];
index ace8e6889ec9116f81ac802d2fdb464ce4d1a85d..a40a7e1d88e9f457f9f415364e2972922961347b 100644 (file)
@@ -84,7 +84,10 @@ class CredentialsManager implements ICredentialsManager {
                        ->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)))
                        ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
                ;
-               $result = $qb->execute()->fetch();
+
+               $qResult = $qb->execute();
+               $result = $qResult->fetch();
+               $qResult->closeCursor();
 
                if (!$result) {
                        return null;
index e05c4e9184e900c98cd8b28914fd64217f909514..de795143005b4f7f3f3de3c3c8c89c1c31e469c9 100644 (file)
@@ -194,6 +194,7 @@ class Share extends Constants {
                        }
                        $shares[] = $row;
                }
+               $result->closeCursor();
 
                //if didn't found a result than let's look for a group share.
                if (empty($shares) && $user !== null) {
@@ -692,9 +693,9 @@ class Share extends Constants {
                                                ->from('share')
                                                ->where($query->expr()->eq('id', $query->createNamedParameter($row['parent'])));
 
-                                       $result = $query->execute();
-                                       $parentRow = $result->fetch();
-                                       $result->closeCursor();
+                                       $parentResult = $query->execute();
+                                       $parentRow = $parentResult->fetch();
+                                       $parentResult->closeCursor();
 
                                        if ($parentRow === false) {
                                                \OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
index 4613b6247f4fbfca4b385fd595c2672c18c8c083..155efccfaa7033f679e7b9666a94e65f0758bdc3 100644 (file)
@@ -102,6 +102,10 @@ class TagManager implements ITagManager {
                        ->andWhere($query->expr()->eq('c.type', $query->createNamedParameter($objectType)))
                        ->andWhere($query->expr()->eq('c.category', $query->createNamedParameter(ITags::TAG_FAVORITE)));
 
-               return $query->execute()->fetchAll(\PDO::FETCH_COLUMN);
+               $result = $query->execute();
+               $users = $result->fetchAll(\PDO::FETCH_COLUMN);
+               $result->closeCursor();
+
+               return $users;
        }
 }
index 3fc66c69d6cc236fd82a6e566c8cb9f4b10893c0..ef901850bbd3ac3746fbbcc77329fe1d353ea89a 100644 (file)
@@ -285,6 +285,7 @@ class Tags implements ITags {
                        $stmt = \OC_DB::prepare($sql);
                        $result = $stmt->execute([$tagId]);
                        if ($result === null) {
+                               $stmt->closeCursor();
                                \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR);
                                return false;
                        }
@@ -301,6 +302,7 @@ class Tags implements ITags {
                        while ($row = $result->fetchRow()) {
                                $ids[] = (int)$row['objid'];
                        }
+                       $result->closeCursor();
                }
 
                return $ids;
@@ -538,6 +540,7 @@ class Tags implements ITags {
                                                ]);
                                        }
                                }
+                               $result->closeCursor();
                        } catch (\Exception $e) {
                                \OC::$server->getLogger()->logException($e, [
                                        'message' => __METHOD__,
index d4072caf28ea21b61b6d6fdaaeaaef65fdee49b9..4cd941c3311befb3e032d0b413c366d817ff5a7a 100644 (file)
@@ -104,6 +104,15 @@ class OC_DB_StatementWrapper {
                return $this->statement->fetchColumn($column);
        }
 
+       /**
+        * Closes the cursor, enabling the statement to be executed again.
+        *
+        * @deprecated Use Result::free() instead.
+        */
+       public function closeCursor(): void {
+               $this->statement->closeCursor();
+       }
+
        /**
         * Binds a PHP variable to a corresponding named or question mark placeholder in the
         * SQL statement that was use to prepare the statement.
index cb0eef5fce2c482cacb31a8ba1fde4e7005c70c7..8741e55dbd6559058dab2b93f44d3dd0516b6664 100644 (file)
@@ -983,6 +983,7 @@ class OC_Util {
                        try {
                                $result = \OC_DB::executeAudited('SHOW SERVER_VERSION');
                                $data = $result->fetchRow();
+                               $result->closeCursor();
                                if (isset($data['server_version'])) {
                                        $version = $data['server_version'];
                                        if (version_compare($version, '9.0.0', '<')) {
index 76abeb5b495767f8352db0ba92bc7e796241b43c..0e086f55e42892964d04982cb45630c4ebe787e1 100644 (file)
@@ -248,7 +248,10 @@ class AccountsManagerTest extends TestCase {
                        ->where($query->expr()->eq('uid', $query->createParameter('uid')))
                        ->setParameter('uid', $uid);
                $query->execute();
-               $result = $query->execute()->fetchAll();
+
+               $qResult = $query->execute();
+               $result = $qResult->fetchAll();
+               $qResult->closeCursor();
 
                if (!empty($result)) {
                        return json_decode($result[0]['data'], true);
index c8b2b7ee13e40c5ad0e000f73e52acf23253b57d..be84cb81cb3087876fcbf64abfb01c99f8480142 100644 (file)
@@ -157,7 +157,7 @@ class ConnectionTest extends \Test\TestCase {
                $this->assertEquals('bar', $this->getTextValueByIntergerField(1));
        }
 
-       
+
        public function testSetValuesOverWritePreconditionFailed() {
                $this->expectException(\OCP\PreConditionNotMetException::class);
 
@@ -335,7 +335,7 @@ class ConnectionTest extends \Test\TestCase {
                $this->assertEquals(0, $result);
        }
 
-       
+
        public function testUniqueConstraintViolating() {
                $this->expectException(\Doctrine\DBAL\Exception\UniqueConstraintViolationException::class);
 
index cf4c746a4dd55e8f9b730623f3b1907d235ec5ff..d4913cbe6f591eed1044f942472e5a009672a8de 100644 (file)
@@ -89,6 +89,8 @@ class LegacyDBTest extends \Test\TestCase {
                $this->assertTrue((bool)$result);
                $row = $result->fetchRow();
                $this->assertFalse($row);
+               $result->closeCursor();
+
                $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
                $result = $query->execute(['fullname test', 'uri_1']);
                $this->assertEquals(1, $result);
@@ -100,6 +102,7 @@ class LegacyDBTest extends \Test\TestCase {
                $this->assertEquals($row['fullname'], 'fullname test');
                $row = $result->fetchRow();
                $this->assertFalse((bool)$row); //PDO returns false, MDB2 returns null
+               $result->closeCursor();
        }
 
        /**
@@ -112,6 +115,7 @@ class LegacyDBTest extends \Test\TestCase {
                $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
                $result = $query->execute(['uri_2']);
                $this->assertTrue((bool)$result);
+               $result->closeCursor();
        }
 
        public function testUNIX_TIMESTAMP() {
@@ -121,6 +125,7 @@ class LegacyDBTest extends \Test\TestCase {
                $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
                $result = $query->execute(['uri_3']);
                $this->assertTrue((bool)$result);
+               $result->closeCursor();
        }
 
        public function testLastInsertId() {
@@ -143,7 +148,12 @@ class LegacyDBTest extends \Test\TestCase {
                $result = $query->execute([$expected, 'uri_1', 'This is a vCard']);
                $this->assertEquals(1, $result);
 
-               $actual = OC_DB::prepare("SELECT `fullname` FROM `$table`")->execute()->fetchOne();
+               $query = OC_DB::prepare("SELECT `fullname` FROM `$table`");
+
+               $result = $query->execute();
+               $actual = $result->fetchOne();
+               $result->closeCursor();
+
                $this->assertSame($expected, $actual);
        }
 
@@ -162,6 +172,7 @@ class LegacyDBTest extends \Test\TestCase {
                $result = $query->execute();
                $this->assertTrue((bool)$result);
                $row = $result->fetchRow();
+               $result->closeCursor();
                $this->assertArrayHasKey($rowname, $row);
                $this->assertEquals($expect, $row[$rowname]);
                $query = OC_DB::prepare('DELETE FROM `' . $table . '`');
@@ -227,14 +238,17 @@ class LegacyDBTest extends \Test\TestCase {
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
                $result = $query->execute(['foobar']);
                $this->assertCount(0, $result->fetchAll());
+               $result->closeCursor();
 
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
                $result = $query->execute(['foobar']);
                $this->assertCount(1, $result->fetchAll());
+               $result->closeCursor();
 
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
                $result = $query->execute(['foo']);
                $this->assertCount(0, $result->fetchAll());
+               $result->closeCursor();
        }
 
        public function testILIKEWildcard() {
@@ -246,26 +260,32 @@ class LegacyDBTest extends \Test\TestCase {
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
                $result = $query->execute(['%bar']);
                $this->assertCount(0, $result->fetchAll());
+               $result->closeCursor();
 
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
                $result = $query->execute(['foo%']);
                $this->assertCount(0, $result->fetchAll());
+               $result->closeCursor();
 
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
                $result = $query->execute(['%ba%']);
                $this->assertCount(0, $result->fetchAll());
+               $result->closeCursor();
 
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
                $result = $query->execute(['%bar']);
                $this->assertCount(1, $result->fetchAll());
+               $result->closeCursor();
 
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
                $result = $query->execute(['foo%']);
                $this->assertCount(1, $result->fetchAll());
+               $result->closeCursor();
 
                $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
                $result = $query->execute(['%ba%']);
                $this->assertCount(1, $result->fetchAll());
+               $result->closeCursor();
        }
 
        /**
@@ -282,7 +302,11 @@ class LegacyDBTest extends \Test\TestCase {
                $result = $query->execute([$expected]);
                $this->assertEquals(1, $result);
 
-               $actual = OC_DB::prepare("SELECT `textfield` FROM `$table`")->execute()->fetchOne();
+               $query = OC_DB::prepare("SELECT `textfield` FROM `$table`");
+
+               $result = $query->execute();
+               $actual = $result->fetchOne();
+               $result->closeCursor();
                $this->assertSame($expected, $actual);
        }
 
index 8e0ce2fe9342b6075ed09512f2ce45551fa26fe1..8fd86a638fea868eca1fb4367c9a3281bc12bbd1 100644 (file)
@@ -67,7 +67,10 @@ class ExpressionBuilderDBTest extends TestCase {
                        ->from('users')
                        ->where($query->expr()->like($query->createNamedParameter($param1), $query->createNamedParameter($param2)));
 
-               $this->assertEquals($match, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals($match, $column);
        }
 
        public function ilikeProvider() {
@@ -101,6 +104,9 @@ class ExpressionBuilderDBTest extends TestCase {
                        ->from('users')
                        ->where($query->expr()->iLike($query->createNamedParameter($param1), $query->createNamedParameter($param2)));
 
-               $this->assertEquals($match, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals($match, $column);
        }
 }
index 3d9baf35b1cb5c8f055546a6789863222fe9282e..fad991bfa90d47c79a1ff6c094a1a1c34aad11a4 100644 (file)
@@ -48,7 +48,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals('foobar', $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals('foobar', $column);
        }
 
        public function testMd5() {
@@ -58,7 +61,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals(md5('foobar'), $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(md5('foobar'), $column);
        }
 
        public function testSubstring() {
@@ -68,7 +74,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals('oo', $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals('oo', $column);
        }
 
        public function testSubstringNoLength() {
@@ -78,7 +87,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals('oobar', $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals('oobar', $column);
        }
 
        public function testLower() {
@@ -88,7 +100,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals('foobar', $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals('foobar', $column);
        }
 
        public function testAdd() {
@@ -98,7 +113,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals(3, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(3, $column);
        }
 
        public function testSubtract() {
@@ -108,7 +126,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals(1, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(1, $column);
        }
 
        public function testCount() {
@@ -118,7 +139,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertGreaterThan(1, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $column = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertGreaterThan(1, $column);
        }
 
        private function setUpMinMax($value) {
@@ -151,7 +175,10 @@ class FunctionBuilderTest extends TestCase {
                        ->where($query->expr()->eq('appid', $query->createNamedParameter('minmax')))
                        ->setMaxResults(1);
 
-               $this->assertEquals(null, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $row = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(null, $row);
        }
 
        public function testMinEmpty() {
@@ -164,7 +191,10 @@ class FunctionBuilderTest extends TestCase {
                        ->where($query->expr()->eq('appid', $query->createNamedParameter('minmax')))
                        ->setMaxResults(1);
 
-               $this->assertEquals(null, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $row = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(null, $row);
        }
 
        public function testMax() {
@@ -180,7 +210,10 @@ class FunctionBuilderTest extends TestCase {
                        ->where($query->expr()->eq('appid', $query->createNamedParameter('minmax')))
                        ->setMaxResults(1);
 
-               $this->assertEquals(20, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $row = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(20, $row);
        }
 
        public function testMin() {
@@ -196,7 +229,10 @@ class FunctionBuilderTest extends TestCase {
                        ->where($query->expr()->eq('appid', $query->createNamedParameter('minmax')))
                        ->setMaxResults(1);
 
-               $this->assertEquals(10, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $row = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(10, $row);
        }
 
        public function testGreatest() {
@@ -206,7 +242,10 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals(2, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $row = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(2, $row);
        }
 
        public function testLeast() {
@@ -216,6 +255,9 @@ class FunctionBuilderTest extends TestCase {
                $query->from('appconfig')
                        ->setMaxResults(1);
 
-               $this->assertEquals(1, $query->execute()->fetchColumn());
+               $result = $query->execute();
+               $row = $result->fetchColumn();
+               $result->closeCursor();
+               $this->assertEquals(1, $row);
        }
 }
index 8f97e0158fec9e1053c660e8705511bf7b4d6f8a..8344460f7579153482bd8b1539fc4c658b45facd 100644 (file)
@@ -136,7 +136,12 @@ class QuerySearchHelperTest extends TestCase {
        private function search(ISearchOperator $operator) {
                $dbOperator = $this->querySearchHelper->searchOperatorToDBExpr($this->builder, $operator);
                $this->builder->andWhere($dbOperator);
-               return $this->builder->execute()->fetchAll(\PDO::FETCH_COLUMN);
+
+               $result = $this->builder->execute();
+               $rows = $result->fetchAll(\PDO::FETCH_COLUMN);
+               $result->closeCursor();
+
+               return $rows;
        }
 
        public function comparisonProvider() {
index ccd37cbb655487cbfde5462c1f04c8c5b92889e1..fd3ec552dd249ca649430a0d7318f1536657e4ae 100644 (file)
@@ -76,7 +76,9 @@ class LoaderTest extends \Test\TestCase {
                        ->from('mimetypes')
                        ->where($qb->expr()->eq('id', $qb->createPositionalParameter($mimetypeId)));
 
-               $mimetype = $qb->execute()->fetch();
+               $result = $qb->execute();
+               $mimetype = $result->fetch();
+               $result->closeCursor();
                $this->assertEquals('testing/mymimetype', $mimetype['mimetype']);
 
                $this->assertEquals('testing/mymimetype', $this->loader->getMimetypeById($mimetypeId));
index ac58538284c22d2217ff03bf480c534fa87dbb67..3f53589d8f15d0be18fbc8d24a2d75e3818e5fa9 100644 (file)
@@ -102,7 +102,12 @@ class DBLockingProviderTest extends LockingProvider {
                $query->select('lock')
                        ->from('file_locks')
                        ->where($query->expr()->eq('key', $query->createNamedParameter($key)));
-               return $query->execute()->fetchColumn();
+
+               $result = $query->execute();
+               $rows = $result->fetchColumn();
+               $result->closeCursor();
+
+               return $rows;
        }
 
        public function testDoubleShared() {