Skip to content

Commit 2a6989f

Browse files
committed
refactor(dbal): move to modern calls
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent 3904da9 commit 2a6989f

69 files changed

Lines changed: 258 additions & 226 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/files/tests/Command/DeleteOrphanedFilesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function testClearFiles(): void {
104104
$this->assertEquals(1, $this->getMountsCount($numericStorageId), 'Asserts that mount is still available');
105105

106106

107-
$deletedRows = $this->connection->executeUpdate('DELETE FROM `*PREFIX*storages` WHERE `id` = ?', [$storageId]);
107+
$deletedRows = $this->connection->executeStatement('DELETE FROM `*PREFIX*storages` WHERE `id` = ?', [$storageId]);
108108
$this->assertNotNull($deletedRows, 'Asserts that storage got deleted');
109109
$this->assertSame(1, $deletedRows, 'Asserts that storage got deleted');
110110

apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function setUp(): void {
7070

7171
$this->connection = Server::get(IDBConnection::class);
7272
// clear occasional leftover shares from other tests
73-
$this->connection->executeUpdate('DELETE FROM `*PREFIX*share`');
73+
$this->connection->executeStatement('DELETE FROM `*PREFIX*share`');
7474

7575
$this->user1 = $this->getUniqueID('user1_');
7676
$this->user2 = $this->getUniqueID('user2_');
@@ -85,7 +85,7 @@ protected function setUp(): void {
8585
}
8686

8787
protected function tearDown(): void {
88-
$this->connection->executeUpdate('DELETE FROM `*PREFIX*share`');
88+
$this->connection->executeStatement('DELETE FROM `*PREFIX*share`');
8989

9090
$userManager = Server::get(IUserManager::class);
9191
$user1 = $userManager->get($this->user1);

apps/files_sharing/tests/SharesReminderJobTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function setUp(): void {
5151
$this->mailer = $this->createMock(IMailer::class);
5252

5353
// Clear occasional leftover shares from other tests
54-
$this->db->executeUpdate('DELETE FROM `*PREFIX*share`');
54+
$this->db->executeStatement('DELETE FROM `*PREFIX*share`');
5555

5656
$this->user1 = $this->getUniqueID('user1_');
5757
$this->user2 = $this->getUniqueID('user2_');
@@ -78,7 +78,7 @@ protected function setUp(): void {
7878
}
7979

8080
protected function tearDown(): void {
81-
$this->db->executeUpdate('DELETE FROM `*PREFIX*share`');
81+
$this->db->executeStatement('DELETE FROM `*PREFIX*share`');
8282

8383
$userManager = Server::get(IUserManager::class);
8484
$user1 = $userManager->get($this->user1);

apps/files_trashbin/tests/TrashbinTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected function tearDown(): void {
144144

145145
// clear trash table
146146
$connection = Server::get(IDBConnection::class);
147-
$connection->executeUpdate('DELETE FROM `*PREFIX*files_trash`');
147+
$connection->executeStatement('DELETE FROM `*PREFIX*files_trash`');
148148

149149
parent::tearDown();
150150
}

lib/base.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig): void {
269269
$result = $qb->select($qb->func()->count('*', 'user_count'))
270270
->from('ldap_user_mapping')
271271
->executeQuery();
272-
$row = $result->fetch();
272+
$row = $result->fetchAssociative();
273273
$result->closeCursor();
274274

275275
$tooBig = ($row['user_count'] > 50);
@@ -280,7 +280,7 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig): void {
280280
$result = $qb->select($qb->func()->count('*', 'user_count'))
281281
->from('user_saml_users')
282282
->executeQuery();
283-
$row = $result->fetch();
283+
$row = $result->fetchAssociative();
284284
$result->closeCursor();
285285

286286
$tooBig = ($row['user_count'] > 50);

lib/private/Accounts/AccountManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ protected function getUser(IUser $user, bool $insertIfNotExists = true): array {
197197
->where($query->expr()->eq('uid', $query->createParameter('uid')))
198198
->setParameter('uid', $uid);
199199
$result = $query->executeQuery();
200-
$accountData = $result->fetchAll();
200+
$accountData = $result->fetchAllAssociative();
201201
$result->closeCursor();
202202

203203
if (empty($accountData)) {
@@ -233,7 +233,7 @@ public function searchUsers(string $property, array $values): array {
233233
$query->setParameter('values', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
234234
$result = $query->executeQuery();
235235

236-
while ($row = $result->fetch()) {
236+
while ($row = $result->fetchAssociative()) {
237237
$matches[$row['uid']] = $row['value'];
238238
}
239239
$result->closeCursor();

lib/private/AppConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ private function loadConfig(?string $app = null, bool $lazy = false): void {
13601360
}
13611361

13621362
$result = $qb->executeQuery();
1363-
$rows = $result->fetchAll();
1363+
$rows = $result->fetchAllAssociative();
13641364
foreach ($rows as $row) {
13651365
// most of the time, 'lazy' is not in the select because its value is already known
13661366
if ($lazy && ((int)$row['lazy']) === 1) {

lib/private/Authentication/Token/PublicKeyTokenMapper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getToken(string $token): PublicKeyToken {
7575
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT)))
7676
->executeQuery();
7777

78-
$data = $result->fetch();
78+
$data = $result->fetchAssociative();
7979
$result->closeCursor();
8080
if ($data === false) {
8181
throw new DoesNotExistException('token does not exist');
@@ -97,7 +97,7 @@ public function getTokenById(int $id): PublicKeyToken {
9797
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT)))
9898
->executeQuery();
9999

100-
$data = $result->fetch();
100+
$data = $result->fetchAssociative();
101101
$result->closeCursor();
102102
if ($data === false) {
103103
throw new DoesNotExistException('token does not exist');
@@ -123,7 +123,7 @@ public function getTokenByUser(string $uid): array {
123123
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT)))
124124
->setMaxResults(1000);
125125
$result = $qb->executeQuery();
126-
$data = $result->fetchAll();
126+
$data = $result->fetchAllAssociative();
127127
$result->closeCursor();
128128

129129
$entities = array_map(function ($row) {
@@ -178,7 +178,7 @@ public function hasExpiredTokens(string $uid): bool {
178178
->setMaxResults(1);
179179

180180
$cursor = $qb->executeQuery();
181-
$data = $cursor->fetchAll();
181+
$data = $cursor->fetchAllAssociative();
182182
$cursor->closeCursor();
183183

184184
return count($data) === 1;
@@ -242,7 +242,7 @@ public function getFirstTokenForUser(string $userId): ?PublicKeyToken {
242242
->orderBy('id');
243243
$result = $qb->executeQuery();
244244

245-
$data = $result->fetch();
245+
$data = $result->fetchAssociative();
246246
$result->closeCursor();
247247
if ($data === false) {
248248
return null;

lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getState(string $uid): array {
3737
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
3838
$result = $query->executeQuery();
3939
$providers = [];
40-
foreach ($result->fetchAll() as $row) {
40+
foreach ($result->fetchAllAssociative() as $row) {
4141
$providers[(string)$row['provider_id']] = (int)$row['enabled'] === 1;
4242
}
4343
$result->closeCursor();
@@ -80,7 +80,7 @@ public function deleteByUser(string $uid): array {
8080
->from(self::TABLE_NAME)
8181
->where($qb1->expr()->eq('uid', $qb1->createNamedParameter($uid)));
8282
$selectResult = $selectQuery->executeQuery();
83-
$rows = $selectResult->fetchAll();
83+
$rows = $selectResult->fetchAllAssociative();
8484
$selectResult->closeCursor();
8585

8686
$qb2 = $this->conn->getQueryBuilder();

lib/private/BackgroundJob/JobList.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function has(IJob|string $job, mixed $argument): bool {
129129
->setMaxResults(1);
130130

131131
$result = $query->executeQuery();
132-
$row = $result->fetch();
132+
$row = $result->fetchAssociative();
133133
$result->closeCursor();
134134

135135
return (bool)$row;
@@ -158,7 +158,7 @@ public function getJobsIterator(IJob|string|null $job, ?int $limit, int $offset)
158158

159159
$result = $query->executeQuery();
160160

161-
while ($row = $result->fetch()) {
161+
while ($row = $result->fetchAssociative()) {
162162
$job = $this->buildJob($row);
163163
if ($job) {
164164
yield $job;
@@ -190,7 +190,7 @@ public function getNext(bool $onlyTimeSensitive = false, ?array $jobClasses = nu
190190
}
191191

192192
$result = $query->executeQuery();
193-
$row = $result->fetch();
193+
$row = $result->fetchAssociative();
194194
$result->closeCursor();
195195

196196
if ($row) {
@@ -293,7 +293,7 @@ public function getDetailsById(string $id): ?array {
293293
->from('jobs')
294294
->where($query->expr()->eq('id', $query->createNamedParameter($id)));
295295
$result = $query->executeQuery();
296-
$row = $result->fetch();
296+
$row = $result->fetchAssociative();
297297
$result->closeCursor();
298298

299299
if ($row) {
@@ -407,7 +407,7 @@ public function hasReservedJob(?string $className = null): bool {
407407

408408
try {
409409
$result = $query->executeQuery();
410-
$hasReservedJobs = $result->fetch() !== false;
410+
$hasReservedJobs = $result->fetchAssociative() !== false;
411411
$result->closeCursor();
412412
return $hasReservedJobs;
413413
} catch (Exception $e) {
@@ -429,7 +429,7 @@ public function countByClass(): array {
429429

430430
$jobs = [];
431431

432-
while (($row = $result->fetch()) !== false) {
432+
while (($row = $result->fetchAssociative()) !== false) {
433433
/**
434434
* @var array{count:int, class:class-string<IJob>} $row
435435
*/

0 commit comments

Comments
 (0)