aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-02-26 18:01:59 +0100
committerRobin Appelman <robin@icewind.nl>2024-09-20 09:55:56 +0200
commit6ea4a976341c193f509fc0e0b4fd5e20082f418e (patch)
tree6df8ec19c44b744bf4f0995bdbb3fb7ed25b03da
parent4ba3d4a31a5a27a7fad6b8928d899ec7247289ca (diff)
downloadnextcloud-server-storage-cache-not-exists.tar.gz
nextcloud-server-storage-cache-not-exists.zip
fix: remove use of depricated insertIfNotExist from Files\Cache\Storagestorage-cache-not-exists
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Files/Cache/Storage.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/private/Files/Cache/Storage.php b/lib/private/Files/Cache/Storage.php
index 8d99a268dc0..ae412ab34b1 100644
--- a/lib/private/Files/Cache/Storage.php
+++ b/lib/private/Files/Cache/Storage.php
@@ -7,6 +7,7 @@
*/
namespace OC\Files\Cache;
+use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Storage\IStorage;
use OCP\IDBConnection;
@@ -56,9 +57,16 @@ class Storage {
$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 {
+ $query = $connection->getQueryBuilder();
+ $query->insert('storages')
+ ->values([
+ 'id' => $query->createNamedParameter($this->storageId),
+ 'available' => $query->createNamedParameter($available, IQueryBuilder::PARAM_INT),
+ ]);
+ try {
+ $query->executeStatement();
+ $this->numericId = $query->getLastInsertId();
+ } catch (UniqueConstraintViolationException $e) {
if ($row = self::getStorageById($this->storageId)) {
$this->numericId = (int)$row['numeric_id'];
} else {