Skip to content

Commit c0982f7

Browse files
committed
Code cleanup.
Signed-off-by: Ole Ostergaard <[email protected]>
1 parent 6247745 commit c0982f7

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

lib/private/DB/Adapter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ public function insertIfNotExist($table, $input, array $compare = null) {
130130
/*
131131
* @suppress SqlInjectionChecker
132132
*/
133-
public function insertIgnoreConflict($table, $input) : int {
133+
public function insertIgnoreConflict(string $table,array $values) : int {
134134
try {
135135
$builder = $this->conn->getQueryBuilder();
136-
$builder->insert($table);
137-
foreach($input as $key => $value) {
138-
$builder->setValue($key, $builder->createNamedParameter($value));
139-
}
136+
$builder->insert($table)->values($values);
137+
// foreach($values as $key => $value) {
138+
// $builder->setValue($key, $builder->createNamedParameter($value));
139+
// }
140140
return $builder->execute();
141141
} catch(UniqueConstraintViolationException $e) {
142142
return 0;

lib/private/DB/AdapterPgSql.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ public function fixupStatement($statement) {
3939
/*
4040
* @suppress SqlInjectionChecker
4141
*/
42-
public function insertIgnoreConflict($table, $input) : int {
42+
public function insertIgnoreConflict(string $table,array $values) : int {
4343
$builder = $this->conn->getQueryBuilder();
44-
$builder->insert($table)
45-
->values($input);
46-
foreach($input as $key => $value) {
47-
$builder->setValue($key, $builder->createNamedParameter($value));
48-
}
44+
$builder->insert($table)->values($values);
45+
// foreach($values as $key => $value) {
46+
// $builder->setValue($key, $builder->createNamedParameter($value));
47+
// }
4948
$queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING';
50-
$inserts = array_values($input);
51-
return $this->conn->executeUpdate($queryString, $inserts);
49+
return $this->conn->executeUpdate($queryString, $builder->getParameters(), $builder->getParameterTypes());
5250
}
5351
}

lib/private/DB/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ public function insertIfNotExist($table, $input, array $compare = null) {
257257
return $this->adapter->insertIfNotExist($table, $input, $compare);
258258
}
259259

260-
public function insertIgnoreConflict($table, $input) : int {
261-
return $this->adapter->insertIgnoreConflict($table, $input);
260+
public function insertIgnoreConflict(string $table, array $values) : int {
261+
return $this->adapter->insertIgnoreConflict($table, $values);
262262
}
263263

264264
private function getType($value) {

lib/private/Lock/DBLockingProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,13 @@ public function __construct(
131131
* @param int $lock
132132
* @return int number of inserted rows
133133
*/
134-
135134
protected function initLockField(string $path, int $lock = 0): int {
136135
$expire = $this->getExpireTime();
137-
return $this->connection->insertIgnoreConflict('file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire]);
136+
return $this->connection->insertIgnoreConflict('file_locks', [
137+
'key' => $path,
138+
'lock' => $lock,
139+
'ttl' => $expire
140+
]);
138141
}
139142

140143
/**

lib/public/IDBConnection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ public function insertIfNotExist($table, $input, array $compare = null);
128128
* Implementation is not fully finished and should not be used!
129129
*
130130
* @param string $table The table name (will replace *PREFIX* with the actual prefix)
131-
* @param array $input data that should be inserted into the table (column name => value)
131+
* @param array $values data that should be inserted into the table (column name => value)
132132
* @return int number of inserted rows
133-
* @since 17.0.0
133+
* @since 16.0.0
134134
*/
135-
public function insertIgnoreConflict($table, $input) : int;
135+
public function insertIgnoreConflict(string $table,array $values) : int;
136136

137137
/**
138138
* Insert or update a row value

0 commit comments

Comments
 (0)