Skip to content

Commit 11a77dd

Browse files
committed
chore: wrap share updates in transaction
Signed-off-by: grnd-alt <git@belakkaf.net>
1 parent 793627c commit 11a77dd

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lib/Sharing/DeckShareProvider.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ private function addShareToDB(
182182
string $target,
183183
int $permissions,
184184
string $token,
185-
?\DateTime $expirationDate
185+
?\DateTime $expirationDate,
186+
?string $attributes = null
186187
): int {
187188
$qb = $this->dbConnection->getQueryBuilder();
188189
$qb->insert('share')
@@ -1062,22 +1063,22 @@ public function getAllShares(): iterable {
10621063
}
10631064

10641065
protected function updateShareAttributes(IShare $share, ?string $data): IShare {
1065-
if ($data !== null && $data !== '') {
1066-
$attributes = $share->getAttributes() ?? $share->newAttributes();
1067-
$compressedAttributes = \json_decode($data, true);
1068-
if ($compressedAttributes === false || $compressedAttributes === null) {
1069-
return $share;
1070-
}
1071-
foreach ($compressedAttributes as $compressedAttribute) {
1072-
$attributes->setAttribute(
1073-
$compressedAttribute[0],
1074-
$compressedAttribute[1],
1075-
$compressedAttribute[2]
1076-
);
1077-
}
1078-
$share->setAttributes($attributes);
1066+
if ($data === null || $data === '') {
1067+
return $share;
10791068
}
1080-
1069+
$attributes = $share->getAttributes() ?? $share->newAttributes();
1070+
$compressedAttributes = \json_decode($data, true);
1071+
if ($compressedAttributes === false || $compressedAttributes === null) {
1072+
return $share;
1073+
}
1074+
foreach ($compressedAttributes as $compressedAttribute) {
1075+
$attributes->setAttribute(
1076+
$compressedAttribute[0],
1077+
$compressedAttribute[1],
1078+
$compressedAttribute[2]
1079+
);
1080+
}
1081+
$share->setAttributes($attributes);
10811082
return $share;
10821083
}
10831084

0 commit comments

Comments
 (0)