aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Cache/Storage.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-11-06 12:06:24 +0100
committerJoas Schilling <coding@schilljs.com>2020-11-09 09:05:15 +0100
commitc07720de77282408ddf00311bb13c27d7a898d84 (patch)
tree1fd19efca06d588c6033fc9c31076b770ece6e92 /lib/private/Files/Cache/Storage.php
parentf5be2c722a6c32cb9bc562cf79b97279d60c6290 (diff)
downloadnextcloud-server-c07720de77282408ddf00311bb13c27d7a898d84.tar.gz
nextcloud-server-c07720de77282408ddf00311bb13c27d7a898d84.zip
Use query builder instead of OC_DB in OC\Files\*
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Files/Cache/Storage.php')
-rw-r--r--lib/private/Files/Cache/Storage.php33
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/private/Files/Cache/Storage.php b/lib/private/Files/Cache/Storage.php
index 62228e16290..b11cd5799de 100644
--- a/lib/private/Files/Cache/Storage.php
+++ b/lib/private/Files/Cache/Storage.php
@@ -126,9 +126,14 @@ class Storage {
* @return string|null either the storage id string or null if the numeric id is not known
*/
public static function getStorageId($numericId) {
- $sql = 'SELECT `id` FROM `*PREFIX*storages` WHERE `numeric_id` = ?';
- $result = \OC_DB::executeAudited($sql, [$numericId]);
- if ($row = $result->fetchRow()) {
+ $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $query->select('id')
+ ->from('storages')
+ ->where($query->expr()->eq('numeric_id', $query->createNamedParameter($numericId)));
+ $result = $query->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+ if ($row) {
return $row['id'];
} else {
return null;
@@ -170,9 +175,14 @@ class Storage {
* @param int $delay amount of seconds to delay reconsidering that storage further
*/
public function setAvailability($isAvailable, int $delay = 0) {
- $sql = 'UPDATE `*PREFIX*storages` SET `available` = ?, `last_checked` = ? WHERE `id` = ?';
$available = $isAvailable ? 1 : 0;
- \OC_DB::executeAudited($sql, [$available, time() + $delay, $this->storageId]);
+
+ $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $query->update('storages')
+ ->set('available', $query->createNamedParameter($available))
+ ->set('last_checked', $query->createNamedParameter(time() + $delay))
+ ->where($query->expr()->eq('id', $query->createNamedParameter($this->storageId)));
+ $query->execute();
}
/**
@@ -193,12 +203,17 @@ class Storage {
public static function remove($storageId) {
$storageId = self::adjustStorageId($storageId);
$numericId = self::getNumericStorageId($storageId);
- $sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?';
- \OC_DB::executeAudited($sql, [$storageId]);
+
+ $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $query->delete('storages')
+ ->where($query->expr()->eq('id', $query->createNamedParameter($storageId)));
+ $query->execute();
if (!is_null($numericId)) {
- $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?';
- \OC_DB::executeAudited($sql, [$numericId]);
+ $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $query->delete('filecache')
+ ->where($query->expr()->eq('storage', $query->createNamedParameter($numericId)));
+ $query->execute();
}
}
}