diff options
Diffstat (limited to 'apps')
17 files changed, 155 insertions, 43 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 8b66420560d..4ff51a5f527 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -249,7 +249,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; } /** @@ -2347,7 +2350,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') diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index b9aecbd1c36..bd881eb06c2 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -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; } /** diff --git a/apps/dav/lib/Migration/BuildCalendarSearchIndex.php b/apps/dav/lib/Migration/BuildCalendarSearchIndex.php index d16873fee20..117cef7d7bf 100644 --- a/apps/dav/lib/Migration/BuildCalendarSearchIndex.php +++ b/apps/dav/lib/Migration/BuildCalendarSearchIndex.php @@ -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, [ diff --git a/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php b/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php index 2aef1617df8..58e798f42c9 100644 --- a/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php +++ b/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php @@ -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, [ diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index fe83a41038c..a8c7a781724 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -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']); diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php index 3e22193fcbf..2633ccf544f 100644 --- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php @@ -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() { diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index ac6f3c96a16..395d34cc7e5 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -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(); diff --git a/apps/federation/lib/DbHandler.php b/apps/federation/lib/DbHandler.php index c30bbf51ad8..5499b4547b6 100644 --- a/apps/federation/lib/DbHandler.php +++ b/apps/federation/lib/DbHandler.php @@ -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); diff --git a/apps/federation/tests/DbHandlerTest.php b/apps/federation/tests/DbHandlerTest.php index 7a06b2c9daa..ee972458747 100644 --- a/apps/federation/tests/DbHandlerTest.php +++ b/apps/federation/tests/DbHandlerTest.php @@ -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']); } diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php index eaa5815cd30..f6ccda9561f 100644 --- a/apps/files_external/lib/Service/DBConfigService.php +++ b/apps/files_external/lib/Service/DBConfigService.php @@ -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) { diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index 5f10a9b9498..b1118a57140 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -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)); } diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php index dd03ffc6668..b163583bf11 100644 --- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php +++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php @@ -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; } diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php index 05cb34ac506..a0e8720d17c 100644 --- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php +++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php @@ -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) { diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 2ad67e5559a..91f3cec21ee 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -1002,10 +1002,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) { diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php index d7a654e519d..329089bcafa 100644 --- a/apps/files_trashbin/tests/Command/CleanUpTest.php +++ b/apps/files_trashbin/tests/Command/CleanUpTest.php @@ -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']); diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index 2cc39ff9628..6285de2188c 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -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)); diff --git a/apps/user_ldap/lib/Jobs/UpdateGroups.php b/apps/user_ldap/lib/Jobs/UpdateGroups.php index ce45d90af3e..4b5e6ff63db 100644 --- a/apps/user_ldap/lib/Jobs/UpdateGroups.php +++ b/apps/user_ldap/lib/Jobs/UpdateGroups.php @@ -123,7 +123,10 @@ class UpdateGroups extends TimedJob { $qb = $this->dbc->getQueryBuilder(); $qb->select(['owncloudname', 'owncloudusers']) ->from('ldap_group_members'); - $result = $qb->execute()->fetchAll(); + + $qResult = $qb->execute(); + $result = $qResult->fetchAll(); + $qResult->closeCursor(); $this->groupsFromDB = []; foreach ($result as $dataset) { |