Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ public function getCalendarsForUserCount($principalUri, $excludeBirthday = true)
$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;
}

/**
Expand Down Expand Up @@ -2346,7 +2349,9 @@ protected function addChange($calendarId, $objectUri, $operation, $calendarType
$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')
Expand Down
5 changes: 4 additions & 1 deletion apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ public function getAddressBooksForUserCount($principalUri) {
->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;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion apps/dav/lib/Migration/BuildCalendarSearchIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public function run(IOutput $output) {
$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, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public function run(IOutput $output) {
$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, [
Expand Down
22 changes: 19 additions & 3 deletions apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,12 @@ public function testUpdateProperties() {
$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));

Expand All @@ -569,7 +574,12 @@ public function testUpdateProperties() {
$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));

Expand Down Expand Up @@ -609,7 +619,13 @@ public function testPurgeProperties() {
$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']);
Expand Down
7 changes: 6 additions & 1 deletion apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ protected function getProps(string $user, string $path) {
->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() {
Expand Down
8 changes: 6 additions & 2 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ protected function getShareFromExternalShareTable(IShare $share) {
$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];
Expand Down Expand Up @@ -483,7 +485,9 @@ public function getRemoteId(IShare $share) {
$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();
Expand Down
6 changes: 4 additions & 2 deletions apps/federation/lib/DbHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ public function getServerById($id) {
$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);
Expand Down
50 changes: 40 additions & 10 deletions apps/federation/tests/DbHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ protected function setUp(): void {
);

$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');
}

Expand All @@ -83,7 +86,10 @@ public function testAddServer($url, $expectedUrl, $expectedHash) {
$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']);
Expand All @@ -104,7 +110,10 @@ public function testRemove() {
$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']);
Expand All @@ -113,7 +122,10 @@ public function testRemove() {

$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']);
Expand Down Expand Up @@ -165,12 +177,18 @@ public function dataTestServerExists() {
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']);
}
Expand All @@ -186,12 +204,18 @@ public function testGetToken() {
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']);
}
Expand All @@ -207,12 +231,18 @@ public function testGetSharedSecret() {
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']);
}
Expand Down
5 changes: 4 additions & 1 deletion apps/files_external/lib/Service/DBConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,10 @@ private function selectForMounts($table, array $fields, array $mountIds) {
$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) {
Expand Down
5 changes: 4 additions & 1 deletion apps/files_external/tests/Service/StoragesServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ public function testDeleteStorage($backendOptions, $rustyStorageId, $expectedCou
$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));
}

Expand Down
10 changes: 8 additions & 2 deletions apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ private function doesStorageExist($numericId) {
$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;
}
Expand All @@ -151,7 +154,10 @@ private function doesStorageExist($numericId) {
$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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ public function testAddPasswordColumn() {
$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) {
Expand Down
6 changes: 5 additions & 1 deletion apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,14 @@ private static function getVersionsFromTrash($filename, $timestamp, $user) {
->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) {
Expand Down
10 changes: 7 additions & 3 deletions apps/files_trashbin/tests/Command/CleanUpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ public function testRemoveDeletedFiles($nodeExists) {
// 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']);
Expand Down
Loading