Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-11-09 12:35:12 +0300
committerMorris Jobke <hey@morrisjobke.de>2018-11-09 12:38:20 +0300
commit230e93f5756dca187f77c8df3cf69e3d7e3d05ff (patch)
tree2d5d508295563d881127cd2460d4d3d609832634 /lib/public
parentda57aaf8147778a6a2e4d3ccb0bd130ddeef2fcb (diff)
Catch UniqueConstraintViolationException inside insertIfNotExist
This is the most common case for the usage of this method. See also https://github.com/nextcloud/server/issues/12369 and the linked tickets. Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/IDBConnection.php4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php
index 4e450eae736..204d7bc99ed 100644
--- a/lib/public/IDBConnection.php
+++ b/lib/public/IDBConnection.php
@@ -104,7 +104,9 @@ interface IDBConnection {
public function lastInsertId($table = null);
/**
- * Insert a row if the matching row does not exists.
+ * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
+ * it is needed that there is also a unique constraint on the values. Then this method will
+ * catch the exception and return 0.
*
* @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)