aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorOle Ostergaard <ole.c.ostergaard@gmail.com>2019-02-26 14:08:55 +0100
committerOle Ostergaard <ole.c.ostergaard@gmail.com>2019-03-21 11:42:00 +0100
commit0d778fcc4e489f541271fa25087777a9253d129e (patch)
tree158dc4b47060c79394580c3365dd778d55ffed6b /lib/private
parent63350423d48b1d4fef842666ae3b7627396ca8d1 (diff)
downloadnextcloud-server-0d778fcc4e489f541271fa25087777a9253d129e.tar.gz
nextcloud-server-0d778fcc4e489f541271fa25087777a9253d129e.zip
Code cleanup.
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/DB/Adapter.php4
-rw-r--r--lib/private/DB/AdapterPgSql.php10
-rw-r--r--lib/private/DB/Connection.php4
-rw-r--r--lib/private/Lock/DBLockingProvider.php7
4 files changed, 13 insertions, 12 deletions
diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php
index a9c20c735e0..0df2e0769f7 100644
--- a/lib/private/DB/Adapter.php
+++ b/lib/private/DB/Adapter.php
@@ -130,11 +130,11 @@ class Adapter {
/*
* @suppress SqlInjectionChecker
*/
- public function insertIgnoreConflict($table, $input) : int {
+ public function insertIgnoreConflict(string $table,array $values) : int {
try {
$builder = $this->conn->getQueryBuilder();
$builder->insert($table);
- foreach($input as $key => $value) {
+ foreach($values as $key => $value) {
$builder->setValue($key, $builder->createNamedParameter($value));
}
return $builder->execute();
diff --git a/lib/private/DB/AdapterPgSql.php b/lib/private/DB/AdapterPgSql.php
index de4fca3ebf4..b7b473f37c2 100644
--- a/lib/private/DB/AdapterPgSql.php
+++ b/lib/private/DB/AdapterPgSql.php
@@ -39,15 +39,13 @@ class AdapterPgSql extends Adapter {
/*
* @suppress SqlInjectionChecker
*/
- public function insertIgnoreConflict($table, $input) : int {
+ public function insertIgnoreConflict(string $table,array $values) : int {
$builder = $this->conn->getQueryBuilder();
- $builder->insert($table)
- ->values($input);
- foreach($input as $key => $value) {
+ $builder->insert($table);
+ foreach($values as $key => $value) {
$builder->setValue($key, $builder->createNamedParameter($value));
}
$queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING';
- $inserts = array_values($input);
- return $this->conn->executeUpdate($queryString, $inserts);
+ return $this->conn->executeUpdate($queryString, $builder->getParameters(), $builder->getParameterTypes());
}
}
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index 12a0af6121e..506f4bcd4c9 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -257,8 +257,8 @@ class Connection extends ReconnectWrapper implements IDBConnection {
return $this->adapter->insertIfNotExist($table, $input, $compare);
}
- public function insertIgnoreConflict($table, $input) : int {
- return $this->adapter->insertIgnoreConflict($table, $input);
+ public function insertIgnoreConflict(string $table, array $values) : int {
+ return $this->adapter->insertIgnoreConflict($table, $values);
}
private function getType($value) {
diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php
index a1859047fe6..bd76385d85d 100644
--- a/lib/private/Lock/DBLockingProvider.php
+++ b/lib/private/Lock/DBLockingProvider.php
@@ -131,10 +131,13 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param int $lock
* @return int number of inserted rows
*/
-
protected function initLockField(string $path, int $lock = 0): int {
$expire = $this->getExpireTime();
- return $this->connection->insertIgnoreConflict('file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire]);
+ return $this->connection->insertIgnoreConflict('file_locks', [
+ 'key' => $path,
+ 'lock' => $lock,
+ 'ttl' => $expire
+ ]);
}
/**