Skip to content

Commit 6cbada9

Browse files
committed
Improve delete rollbacks
1 parent ba0a8c9 commit 6cbada9

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/Database/Database.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,15 +2916,14 @@ public function deleteAttribute(string $collection, string $id): bool
29162916
$collection->setAttribute('attributes', \array_values($attributes));
29172917
$collection->setAttribute('indexes', \array_values($indexes));
29182918

2919-
$success = false;
2919+
$shouldRollback = false;
29202920
try {
29212921
if (!$this->adapter->deleteAttribute($collection->getId(), $id)) {
29222922
throw new DatabaseException('Failed to delete attribute');
29232923
}
2924-
$success = true;
2924+
$shouldRollback = true;
29252925
} catch (NotFoundException) {
29262926
// Ignore
2927-
$success = false;
29282927
}
29292928

29302929
$this->updateMetadata(
@@ -2938,7 +2937,7 @@ public function deleteAttribute(string $collection, string $id): bool
29382937
$attribute['array'] ?? false,
29392938
$attribute['required'] ?? false
29402939
),
2941-
shouldRollback: $success,
2940+
shouldRollback: $shouldRollback,
29422941
operationDescription: "attribute deletion '{$id}'",
29432942
silentRollback: true
29442943
);

0 commit comments

Comments
 (0)