Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: Migrate use of deprecated method insertIfNotExists in Storage co…
…nstructor

Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Apr 24, 2025
commit 53b986db3bc50596f053a90484cfacac8b75dd9c
12 changes: 9 additions & 3 deletions lib/private/Files/Cache/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ public function __construct($storage, $isAvailable, IDBConnection $connection) {
$this->numericId = (int)$row['numeric_id'];
} else {
$available = $isAvailable ? 1 : 0;
if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $available])) {
$this->numericId = $connection->lastInsertId('*PREFIX*storages');
} else {
try {
$query = $connection->getQueryBuilder();
$query->insert('storages')
->set('id', $query->createNamedParameter($this->storageId))
->set('available', $query->createNamedParameter($available));
$query->executeStatement();
$this->numericId = $query->getLastInsertId();
} catch (\Exception $e) {
//TODO: catch only conflict
if ($row = self::getStorageById($this->storageId)) {
$this->numericId = (int)$row['numeric_id'];
} else {
Expand Down
Loading