Skip to content

Commit 3e0c3e9

Browse files
committed
refactor(QueryBuilder): Migrate away from deprecated execute method
Signed-off-by: Jonas <jonas@freesources.org>
1 parent da7402f commit 3e0c3e9

18 files changed

+91
-83
lines changed

lib/Command/CirclesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function (Member $member): string {
286286
// $circlesQueryHelper->addCircleDetails('test', 'shared_to');
287287
//
288288
// $items = [];
289-
// $cursor = $qb->execute();
289+
// $cursor = $qb->executeQuery();
290290
// while ($row = $cursor->fetch()) {
291291
// try {
292292
// $items[] = [

lib/Command/MigrateCustomGroups.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private function getSharedIds(string $groupUri): array {
231231
->where($select->expr()->eq('share_type', $select->createNamedParameter(IShare::TYPE_GROUP)));
232232

233233
$shareIds = [];
234-
$result = $select->execute();
234+
$result = $select->executeQuery();
235235
while ($row = $result->fetch()) {
236236
$with = $row['share_with'];
237237
if (!str_starts_with($with, 'customgroup_')

lib/Db/AccountsRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getAccountData(string $userId): array {
2121

2222
$this->limitToDBField($qb, 'uid', $userId);
2323

24-
$cursor = $qb->execute();
24+
$cursor = $qb->executeQuery();
2525
$data = $cursor->fetch();
2626
$cursor->closeCursor();
2727

@@ -46,7 +46,7 @@ public function getFromUserId(string $userId): array {
4646

4747
$this->limitToDBField($qb, 'uid', $userId);
4848

49-
$cursor = $qb->execute();
49+
$cursor = $qb->executeQuery();
5050
$data = $cursor->fetch();
5151
$cursor->closeCursor();
5252

@@ -66,7 +66,7 @@ public function getAll(): array {
6666
$qb = $this->getAccountsSelectSql();
6767

6868
$accounts = [];
69-
$cursor = $qb->execute();
69+
$cursor = $qb->executeQuery();
7070
while ($data = $cursor->fetch()) {
7171
$account = $this->parseAccountsSelectSql($data);
7272
$accounts[$account['userId']] = $account;

lib/Db/CircleRequest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function save(Circle $circle): void {
5151
->setValue('settings', $qb->createNamedParameter(json_encode($circle->getSettings())))
5252
->setValue('config', $qb->createNamedParameter($circle->getConfig()));
5353

54-
$qb->execute();
54+
$qb->executeStatement();
5555
}
5656

5757

@@ -67,7 +67,7 @@ public function edit(Circle $circle): void {
6767

6868
$qb->limitToUniqueId($circle->getSingleId());
6969

70-
$qb->execute();
70+
$qb->executeStatement();
7171
}
7272

7373
/**
@@ -83,7 +83,7 @@ public function update(Circle $circle) {
8383

8484
$qb->limitToUniqueId($circle->getSingleId());
8585

86-
$qb->execute();
86+
$qb->executeStatement();
8787
}
8888

8989

@@ -112,7 +112,7 @@ public function updateDisplayName(string $singleId, string $displayName): void {
112112

113113
$qb->limitToUniqueId($singleId);
114114

115-
$qb->execute();
115+
$qb->executeStatement();
116116
}
117117

118118

@@ -125,7 +125,7 @@ public function updateConfig(Circle $circle) {
125125

126126
$qb->limitToUniqueId($circle->getSingleId());
127127

128-
$qb->execute();
128+
$qb->executeStatement();
129129
}
130130

131131

@@ -137,7 +137,7 @@ public function updateSettings(Circle $circle) {
137137
$qb->set('settings', $qb->createNamedParameter(json_encode($circle->getSettings())));
138138
$qb->limitToUniqueId($circle->getSingleId());
139139

140-
$qb->execute();
140+
$qb->executeStatement();
141141
}
142142

143143

@@ -513,7 +513,7 @@ public function delete(Circle $circle): void {
513513
$qb = $this->getCircleDeleteSql();
514514
$qb->limitToUniqueId($circle->getSingleId());
515515

516-
$qb->execute();
516+
$qb->executeStatement();
517517
}
518518

519519

@@ -524,6 +524,6 @@ public function deleteFederatedUser(IFederatedUser $federatedUser): void {
524524
$qb = $this->getCircleDeleteSql();
525525
$qb->limitToUniqueId($federatedUser->getSingleId());
526526

527-
$qb->execute();
527+
$qb->executeStatement();
528528
}
529529
}

lib/Db/CoreRequestBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public function cleanDatabase(bool $shares = false): void {
244244
$qb = $this->getQueryBuilder();
245245
try {
246246
$qb->delete($table);
247-
$qb->execute();
247+
$qb->executeStatement();
248248
} catch (Exception $e) {
249249
}
250250
}
@@ -254,7 +254,7 @@ public function cleanDatabase(bool $shares = false): void {
254254
$expr = $qb->expr();
255255
$qb->delete(self::TABLE_SHARE);
256256
$qb->where($expr->eq('share_type', $qb->createNamedParameter(IShare::TYPE_CIRCLE)));
257-
$qb->execute();
257+
$qb->executeStatement();
258258
}
259259
}
260260

@@ -292,7 +292,7 @@ public function uninstallFromMigrations() {
292292
$qb->limit('app', 'circles');
293293
$qb->unlike('version', '001%');
294294

295-
$qb->execute();
295+
$qb->executeStatement();
296296
}
297297

298298
/**
@@ -302,6 +302,6 @@ public function uninstallFromJobs() {
302302
$qb = $this->getQueryBuilder();
303303
// $qb->delete('jobs');
304304
// $qb->where($this->exprLimitToDBField($qb, 'class', 'OCA\Circles\', true, true));
305-
// $qb->execute();
305+
// $qb->executeStatement();
306306
}
307307
}

lib/Db/EventWrapperRequest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace OCA\Circles\Db;
1313

14-
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
14+
use OC\DB\Exceptions\DbalException;
1515
use OCA\Circles\Model\Federated\EventWrapper;
1616
use Psr\Log\LoggerInterface;
1717

@@ -41,8 +41,12 @@ public function save(EventWrapper $wrapper): void {
4141
->setValue('creation', $qb->createNamedParameter($wrapper->getCreation()));
4242

4343
try {
44-
$qb->execute();
45-
} catch (UniqueConstraintViolationException $e) {
44+
$qb->executeStatement();
45+
} catch (DbalException $e) {
46+
if ($e->getReason() !== DbalException::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
47+
throw $e;
48+
}
49+
4650
$logger = \OCP\Server::get(LoggerInterface::class);
4751
$logger->warning('issue while storing event', ['exception' => $e]);
4852
}
@@ -60,7 +64,7 @@ public function update(EventWrapper $wrapper): void {
6064
$qb->limitToInstance($wrapper->getInstance());
6165
$qb->limitToToken($wrapper->getToken());
6266

63-
$qb->execute();
67+
$qb->executeStatement();
6468
}
6569

6670

@@ -74,7 +78,7 @@ public function updateAll(string $token, int $status): void {
7478

7579
$qb->limitToToken($token);
7680

77-
$qb->execute();
81+
$qb->executeStatement();
7882
}
7983

8084

lib/Db/FileSharesRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function removeSharesFromMember(DeprecatedMember $member): void {
3232
$expr->eq('uid_initiator', $qb->createNamedParameter($member->getUserId())),
3333
));
3434

35-
$qb->execute();
35+
$qb->executeStatement();
3636
}
3737

3838

@@ -48,7 +48,7 @@ public function removeSharesToCircleId(string $circleId): void {
4848
$expr->eq('share_with', $qb->createNamedParameter($circleId)),
4949
));
5050

51-
$qb->execute();
51+
$qb->executeStatement();
5252
}
5353

5454

@@ -64,7 +64,7 @@ public function getSharesForCircle(string $circleId): array {
6464
$this->limitToShareType($qb, self::SHARE_TYPE);
6565

6666
$shares = [];
67-
$cursor = $qb->execute();
67+
$cursor = $qb->executeQuery();
6868
while ($data = $cursor->fetch()) {
6969
$shares[] = $data;
7070
}
@@ -86,7 +86,7 @@ public function getShares(): array {
8686
$qb->andWhere($expr->isNull($this->default_select_alias . '.parent'));
8787

8888
$shares = [];
89-
$cursor = $qb->execute();
89+
$cursor = $qb->executeQuery();
9090
while ($data = $cursor->fetch()) {
9191
$shares[] = $data;
9292
}

lib/Db/GSSharesRequest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function create(GSShare $gsShare): void {
3838
->setValue('parent', $qb->createNamedParameter($gsShare->getParent()))
3939
->setValue('mountpoint', $qb->createNamedParameter($gsShare->getMountPoint()))
4040
->setValue('mountpoint_hash', $qb->createNamedParameter($hash));
41-
$qb->execute();
41+
$qb->executeStatement();
4242
}
4343

4444

@@ -54,7 +54,7 @@ public function getForUser(string $userId): array {
5454
$this->leftJoinMountPoint($qb, $userId);
5555

5656
$shares = [];
57-
$cursor = $qb->execute();
57+
$cursor = $qb->executeQuery();
5858
while ($data = $cursor->fetch()) {
5959
$shares[] = $this->parseGSSharesSelectSql($data);
6060
}
@@ -73,7 +73,7 @@ public function removeGSSharesFromMember(DeprecatedMember $member) {
7373
$this->limitToInstance($qb, $member->getInstance());
7474
$this->limitToOwner($qb, $member->getUserId());
7575

76-
$qb->execute();
76+
$qb->executeStatement();
7777
}
7878

7979

@@ -126,7 +126,7 @@ public function getShareMountPointByPath(string $userId, string $target): GSShar
126126
$this->limitToMountpointHash($qb, $targetHash);
127127

128128
$shares = [];
129-
$cursor = $qb->execute();
129+
$cursor = $qb->executeQuery();
130130
$data = $cursor->fetch();
131131

132132
if ($data === false) {
@@ -151,7 +151,7 @@ public function getShareMountPointById(int $gsShareId, string $userId): GSShareM
151151
$this->limitToUserId($qb, $userId);
152152

153153
$shares = [];
154-
$cursor = $qb->execute();
154+
$cursor = $qb->executeQuery();
155155
$data = $cursor->fetch();
156156
if ($data === false) {
157157
throw new ShareNotFound();
@@ -173,7 +173,7 @@ public function generateShareMountPoint(GSShareMountpoint $mountpoint) {
173173
->setValue('share_id', $qb->createNamedParameter($mountpoint->getShareId()))
174174
->setValue('mountpoint', $qb->createNamedParameter($mountpoint->getMountPoint()))
175175
->setValue('mountpoint_hash', $qb->createNamedParameter($hash));
176-
$qb->execute();
176+
$qb->executeStatement();
177177
}
178178

179179

@@ -192,7 +192,7 @@ public function updateShareMountPoint(GSShareMountpoint $mountpoint) {
192192

193193
$this->limitToShareId($qb, $mountpoint->getShareId());
194194
$this->limitToUserId($qb, $mountpoint->getUserId());
195-
$nb = $qb->execute();
195+
$nb = $qb->executeStatement();
196196

197197
return ($nb === 1);
198198
}

lib/Db/MemberRequest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function save(Member $member): void {
5353
$qb->setValue('invited_by', $qb->createNamedParameter($member->getInvitedBy()->getSingleId()));
5454
}
5555

56-
$qb->execute();
56+
$qb->executeStatement();
5757
}
5858

5959

@@ -77,7 +77,7 @@ public function update(Member $member): void {
7777
$qb->limitToCircleId($member->getCircleId());
7878
$qb->limitToSingleId($member->getSingleId());
7979

80-
$qb->execute();
80+
$qb->executeStatement();
8181
}
8282

8383

@@ -112,7 +112,7 @@ public function updateDisplayName(string $singleId, string $displayName, string
112112
$qb->limitToCircleId($circleId);
113113
}
114114

115-
$qb->execute();
115+
$qb->executeStatement();
116116
}
117117

118118

@@ -124,7 +124,7 @@ public function delete(Member $member) {
124124
$qb->limitToCircleId($member->getCircleId());
125125
$qb->limitToSingleId($member->getSingleId());
126126

127-
$qb->execute();
127+
$qb->executeStatement();
128128
}
129129

130130

@@ -137,7 +137,7 @@ public function deleteFederatedUser(IFederatedUser $federatedUser): void {
137137
$qb->limitToMemberId($federatedUser->getSingleId());
138138
$qb->limitToCircleId($federatedUser->getSingleId());
139139

140-
$qb->execute();
140+
$qb->executeStatement();
141141
}
142142

143143

@@ -150,7 +150,7 @@ public function deleteFederatedUserFromCircle(IFederatedUser $federatedUser, Cir
150150
$qb->limitToSingleId($federatedUser->getSingleId());
151151
$qb->limitToCircleId($circle->getSingleId());
152152

153-
$qb->execute();
153+
$qb->executeStatement();
154154
}
155155

156156

@@ -167,7 +167,7 @@ public function deleteAllFromCircle(Circle $circle) {
167167
)
168168
);
169169

170-
$qb->execute();
170+
$qb->executeStatement();
171171
}
172172

173173

@@ -182,7 +182,7 @@ public function updateLevel(Member $member): void {
182182
$qb->limitToCircleId($member->getCircleId());
183183
$qb->limitToSingleId($member->getSingleId());
184184

185-
$qb->execute();
185+
$qb->executeStatement();
186186
}
187187

188188

0 commit comments

Comments
 (0)