summaryrefslogtreecommitdiffstats
path: root/lib/private/allconfig.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/allconfig.php')
-rw-r--r--lib/private/allconfig.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php
index 00defd920d7..b8bba7986e6 100644
--- a/lib/private/allconfig.php
+++ b/lib/private/allconfig.php
@@ -189,11 +189,18 @@ class AllConfig implements \OCP\IConfig {
return;
}
- $data = array($value, $userId, $appName, $key);
+ $affectedRows = 0;
if (!$exists && $preCondition === null) {
- $sql = 'INSERT INTO `*PREFIX*preferences` (`configvalue`, `userid`, `appid`, `configkey`)'.
- 'VALUES (?, ?, ?, ?)';
+ $this->connection->insertIfNotExist('*PREFIX*preferences', [
+ 'configvalue' => $value,
+ 'userid' => $userId,
+ 'appid' => $appName,
+ 'configkey' => $key,
+ ], ['configvalue', 'userid', 'appid']);
+ $affectedRows = 1;
} elseif ($exists) {
+ $data = array($value, $userId, $appName, $key);
+
$sql = 'UPDATE `*PREFIX*preferences` SET `configvalue` = ? '.
'WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? ';
@@ -206,8 +213,8 @@ class AllConfig implements \OCP\IConfig {
}
$data[] = $preCondition;
}
+ $affectedRows = $this->connection->executeUpdate($sql, $data);
}
- $affectedRows = $this->connection->executeUpdate($sql, $data);
// only add to the cache if we already loaded data for the user
if ($affectedRows > 0 && isset($this->userCache[$userId])) {