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
4 changes: 2 additions & 2 deletions apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function __construct(
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
}

public function run($argument) {
public function run($argument): void {
$query = $this->db->getQueryBuilder();
$query->delete('calendar_invitations')
->where($query->expr()->lt('expiration',
$query->createNamedParameter($this->time->getTime())))
->execute();
->executeStatement();
}
}
20 changes: 10 additions & 10 deletions apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public function getPrincipalsByPrefix($prefixPath): array {
$query = $this->db->getQueryBuilder();
$query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname'])
->from($this->dbTableName);
$stmt = $query->execute();
$stmt = $query->executeQuery();

$metaDataQuery = $this->db->getQueryBuilder();
$metaDataQuery->select([$this->dbForeignKeyName, 'key', 'value'])
->from($this->dbMetaDataTableName);
$metaDataStmt = $metaDataQuery->execute();
$metaDataStmt = $metaDataQuery->executeQuery();
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);

$metaDataById = [];
Expand Down Expand Up @@ -128,7 +128,7 @@ public function getPrincipalByPath($path) {
->from($this->dbTableName)
->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId)))
->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId)));
$stmt = $query->execute();
$stmt = $query->executeQuery();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);

if (!$row) {
Expand All @@ -139,7 +139,7 @@ public function getPrincipalByPath($path) {
$metaDataQuery->select(['key', 'value'])
->from($this->dbMetaDataTableName)
->where($metaDataQuery->expr()->eq($this->dbForeignKeyName, $metaDataQuery->createNamedParameter($row['id'])));
$metaDataStmt = $metaDataQuery->execute();
$metaDataStmt = $metaDataQuery->executeQuery();
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
$metadata = [];

Expand All @@ -159,7 +159,7 @@ public function getPrincipalById($id): ?array {
$query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname'])
->from($this->dbTableName)
->where($query->expr()->eq('id', $query->createNamedParameter($id)));
$stmt = $query->execute();
$stmt = $query->executeQuery();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);

if (!$row) {
Expand All @@ -170,7 +170,7 @@ public function getPrincipalById($id): ?array {
$metaDataQuery->select(['key', 'value'])
->from($this->dbMetaDataTableName)
->where($metaDataQuery->expr()->eq($this->dbForeignKeyName, $metaDataQuery->createNamedParameter($row['id'])));
$metaDataStmt = $metaDataQuery->execute();
$metaDataStmt = $metaDataQuery->executeQuery();
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
$metadata = [];

Expand Down Expand Up @@ -219,7 +219,7 @@ public function searchPrincipals($prefixPath, array $searchProperties, $test = '
->from($this->dbTableName)
->where($query->expr()->iLike('email', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($value) . '%')));

$stmt = $query->execute();
$stmt = $query->executeQuery();
$principals = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
Expand All @@ -238,7 +238,7 @@ public function searchPrincipals($prefixPath, array $searchProperties, $test = '
->from($this->dbTableName)
->where($query->expr()->iLike('displayname', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($value) . '%')));

$stmt = $query->execute();
$stmt = $query->executeQuery();
$principals = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
Expand Down Expand Up @@ -406,7 +406,7 @@ public function findByUri($uri, $principalPrefix): ?string {
->from($this->dbTableName)
->where($query->expr()->eq('email', $query->createNamedParameter($email)));

$stmt = $query->execute();
$stmt = $query->executeQuery();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);

if (!$row) {
Expand All @@ -433,7 +433,7 @@ public function findByUri($uri, $principalPrefix): ?string {
->from($this->dbTableName)
->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId)))
->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId)));
$stmt = $query->execute();
$stmt = $query->executeQuery();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);

if (!$row) {
Expand Down
24 changes: 8 additions & 16 deletions apps/dav/lib/Migration/BuildSocialSearchIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,21 @@
namespace OCA\DAV\Migration;

use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\IAppConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class BuildSocialSearchIndex implements IRepairStep {

/**
* @param IDBConnection $db
* @param IJobList $jobList
* @param IConfig $config
*/
public function __construct(
private IDBConnection $db,
private IJobList $jobList,
private IConfig $config,
private readonly IDBConnection $db,
private readonly IJobList $jobList,
private readonly IAppConfig $config,
) {
}

/**
* @return string
*/
public function getName() {
public function getName(): string {
return 'Register building of social profile search index as background job';
}

Expand All @@ -38,7 +30,7 @@ public function getName() {
*/
public function run(IOutput $output) {
// only run once
if ($this->config->getAppValue('dav', 'builtSocialSearchIndex') === 'yes') {
if ($this->config->getValueBool('dav', 'builtSocialSearchIndex')) {
$output->info('Repair step already executed');
return;
}
Expand All @@ -47,7 +39,7 @@ public function run(IOutput $output) {
$query->select($query->func()->max('cardid'))
->from('cards_properties')
->where($query->expr()->eq('name', $query->createNamedParameter('X-SOCIALPROFILE')));
$maxId = (int)$query->execute()->fetchOne();
$maxId = (int)$query->executeQuery()->fetchOne();

if ($maxId === 0) {
return;
Expand All @@ -60,6 +52,6 @@ public function run(IOutput $output) {
]);

// no need to redo the repair during next upgrade
$this->config->setAppValue('dav', 'builtSocialSearchIndex', 'yes');
$this->config->setValueBool('dav', 'builtSocialSearchIndex', true);
}
}
4 changes: 2 additions & 2 deletions apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public function getName() {
/**
* @inheritdoc
*/
public function run(IOutput $output) {
public function run(IOutput $output): void {
$query = $this->connection->getQueryBuilder();
$query->select(['principaluri', 'uri'])
->from('calendarsubscriptions');
$stmt = $query->execute();
$stmt = $query->executeQuery();

$count = 0;
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function countSubscriptions(): int {
$query = $qb->select($qb->func()->count('*'))
->from('calendarsubscriptions');

$result = $query->execute();
$result = $query->executeQuery();
$count = $result->fetchOne();
$result->closeCursor();

Expand All @@ -87,7 +87,7 @@ private function checkSubscriptions(): void {
->setMaxResults(self::SUBSCRIPTIONS_CHUNK_SIZE)
->setFirstResult($this->progress);

$result = $query->execute();
$result = $query->executeQuery();
while ($row = $result->fetch()) {
$username = $this->getPrincipal($row['principaluri']);
if (!$this->userManager->userExists($username)) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Migration/Version1008Date20181105104826.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
$qb = $this->connection->getQueryBuilder();
$qb->update('calendarsubscriptions')
->set('source_copy', 'source')
->execute();
->executeStatement();
}
}
2 changes: 1 addition & 1 deletion apps/dav/lib/Migration/Version1008Date20181105110300.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
$qb = $this->connection->getQueryBuilder();
$qb->update('calendarsubscriptions')
->set('source', 'source_copy')
->execute();
->executeStatement();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function testRun(): void {

$queryBuilder = $this->createMock(IQueryBuilder::class);
$expr = $this->createMock(IExpressionBuilder::class);
$stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class);

$this->dbConnection->expects($this->once())
->method('getQueryBuilder')
Expand Down Expand Up @@ -72,9 +71,9 @@ public function testRun(): void {
->with($function)
->willReturn($queryBuilder);
$queryBuilder->expects($this->once())
->method('execute')
->method('executeStatement')
->with()
->willReturn($stmt);
->willReturn(1);

$this->backgroundJob->run([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testRun(): void {
->with('calendarsubscriptions')
->willReturn($queryBuilder);
$queryBuilder->expects($this->once())
->method('execute')
->method('executeQuery')
->willReturn($statement);

$statement->expects($this->exactly(4))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testRun(array $subscriptions, array $userExists, int $deletions)

$result = $this->createMock(IResult::class);

$qb->method('execute')
$qb->method('executeQuery')
->willReturn($result);

$result->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array
$qb->update('federated_reshares')
->set('remote_id', $qb->createNamedParameter(''))
->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1')));
$qb->execute();
$qb->executeStatement();
}
}
8 changes: 4 additions & 4 deletions apps/files/lib/Command/RepairTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function execute(InputInterface $input, OutputInterface $output): int {
'path' => $row['parent_path'] . '/' . $row['name'],
'storage' => $row['parent_storage'],
]);
$query->execute();
$query->executeStatement();
}
}
}
Expand All @@ -78,14 +78,14 @@ private function getFileId(int $storage, string $path) {
->from('filecache')
->where($query->expr()->eq('storage', $query->createNamedParameter($storage)))
->andWhere($query->expr()->eq('path_hash', $query->createNamedParameter(md5($path))));
return $query->execute()->fetch(\PDO::FETCH_COLUMN);
return $query->executeQuery()->fetch(\PDO::FETCH_COLUMN);
}

private function deleteById(int $fileId): void {
$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId)));
$query->execute();
$query->executeStatement();
}

private function findBrokenTreeBits(): array {
Expand All @@ -108,6 +108,6 @@ private function findBrokenTreeBits(): array {
$query->expr()->neq('f.storage', 'p.storage')
));

return $query->execute()->fetchAll();
return $query->executeQuery()->fetchAll();
}
}
2 changes: 1 addition & 1 deletion apps/files_external/lib/Command/Notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private function getStorageIds(int $mountId, string $path): array {
->innerJoin('m', 'filecache', 'f', $qb->expr()->eq('m.storage_id', 'f.storage'))
->where($qb->expr()->eq('mount_id', $qb->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('path_hash', $qb->createNamedParameter($pathHash, IQueryBuilder::PARAM_STR)))
->execute()
->executeQuery()
->fetchAll();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
try {
$qb->setParameter('oldId', $oldId);
$qb->setParameter('newId', $newId);
$qb->execute();
$qb->executeStatement();
$this->logger->info('Migrated s3 storage id for mount with id ' . $mount['mount_id'] . ' to ' . $newId);
} catch (Exception $e) {
$this->logger->error('Failed to migrate external s3 storage id for mount with id ' . $mount['mount_id'], [
Expand All @@ -70,7 +70,7 @@ private function getS3Mounts() {
->innerJoin('m', 'external_config', 'c', 'c.mount_id = m.mount_id')
->where($qb->expr()->eq('m.storage_backend', $qb->createPositionalParameter('amazons3')))
->andWhere($qb->expr()->eq('c.key', $qb->createPositionalParameter('bucket')));
return $qb->execute();
return $qb->executeQuery();
}

/**
Expand All @@ -82,7 +82,7 @@ private function getStorageConfig(int $mountId): array {
->from('external_config')
->where($qb->expr()->eq('mount_id', $qb->createPositionalParameter($mountId)));
$config = [];
foreach ($qb->execute()->fetchAll() as $row) {
foreach ($qb->executeQuery()->fetchAll() as $row) {
$config[$row['key']] = $row['value'];
}
return $config;
Expand Down
23 changes: 16 additions & 7 deletions apps/files_external/lib/Service/DBConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
namespace OCA\Files_External\Service;

use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Security\ICrypto;
Expand Down Expand Up @@ -304,8 +304,11 @@ public function setConfig($mountId, $key, $value) {
->setValue('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))
->setValue('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))
->setValue('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))
->execute();
} catch (UniqueConstraintViolationException $e) {
->executeStatement();
} catch (Exception $e) {
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw $e;
}
$builder = $this->connection->getQueryBuilder();
$query = $builder->update('external_config')
->set('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))
Expand All @@ -327,8 +330,11 @@ public function setOption($mountId, $key, $value) {
->setValue('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))
->setValue('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))
->setValue('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR))
->execute();
} catch (UniqueConstraintViolationException $e) {
->executeStatement();
} catch (Exception $e) {
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw $e;
}
$builder = $this->connection->getQueryBuilder();
$query = $builder->update('external_options')
->set('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR))
Expand All @@ -345,9 +351,12 @@ public function addApplicable($mountId, $type, $value) {
->setValue('mount_id', $builder->createNamedParameter($mountId))
->setValue('type', $builder->createNamedParameter($type))
->setValue('value', $builder->createNamedParameter($value))
->execute();
} catch (UniqueConstraintViolationException $e) {
->executeStatement();
} catch (Exception $e) {
// applicable exists already
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw $e;
}
}
}

Expand Down
Loading
Loading