diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php index a9c20c735e..0df2e0769f 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 de4fca3ebf..b7b473f37c 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 12a0af6121..506f4bcd4c 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 a1859047fe..bd76385d85 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 + ]); } /** diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php index f640ec126f..4c66896a2f 100644 --- a/lib/public/IDBConnection.php +++ b/lib/public/IDBConnection.php @@ -128,11 +128,11 @@ interface IDBConnection { * Implementation is not fully finished and should not be used! * * @param string $table The table name (will replace *PREFIX* with the actual prefix) - * @param array $input data that should be inserted into the table (column name => value) + * @param array $values data that should be inserted into the table (column name => value) * @return int number of inserted rows - * @since 17.0.0 + * @since 16.0.0 */ - public function insertIgnoreConflict($table, $input) : int; + public function insertIgnoreConflict(string $table,array $values) : int; /** * Insert or update a row value