From 5273639d0e16e946ec25a51cfdd6696fde3d07cd Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 9 Nov 2018 12:13:30 +0100 Subject: [PATCH] Add deprecation message ofr insertIfNotExist Signed-off-by: Morris Jobke --- lib/private/DB/Adapter.php | 1 + lib/private/DB/AdapterSqlite.php | 1 + lib/private/DB/Connection.php | 1 + lib/public/IDBConnection.php | 1 + 4 files changed, 4 insertions(+) diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php index 8f06203060..b9a5f272c5 100644 --- a/lib/private/DB/Adapter.php +++ b/lib/private/DB/Adapter.php @@ -92,6 +92,7 @@ class Adapter { * Please note: text fields (clob) must not be used in the compare array * @return int number of inserted rows * @throws \Doctrine\DBAL\DBALException + * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371 */ public function insertIfNotExist($table, $input, array $compare = null) { if (empty($compare)) { diff --git a/lib/private/DB/AdapterSqlite.php b/lib/private/DB/AdapterSqlite.php index 24650829aa..0a482259b9 100644 --- a/lib/private/DB/AdapterSqlite.php +++ b/lib/private/DB/AdapterSqlite.php @@ -63,6 +63,7 @@ class AdapterSqlite extends Adapter { * Please note: text fields (clob) must not be used in the compare array * @return int number of inserted rows * @throws \Doctrine\DBAL\DBALException + * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371 */ public function insertIfNotExist($table, $input, array $compare = null) { if (empty($compare)) { diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 6a64925711..c63ef0067c 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -251,6 +251,7 @@ class Connection extends ReconnectWrapper implements IDBConnection { * Please note: text fields (clob) must not be used in the compare array * @return int number of inserted rows * @throws \Doctrine\DBAL\DBALException + * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371 */ public function insertIfNotExist($table, $input, array $compare = null) { return $this->adapter->insertIfNotExist($table, $input, $compare); diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php index 204d7bc99e..b3abe46484 100644 --- a/lib/public/IDBConnection.php +++ b/lib/public/IDBConnection.php @@ -116,6 +116,7 @@ interface IDBConnection { * @return int number of inserted rows * @throws \Doctrine\DBAL\DBALException * @since 6.0.0 - parameter $compare was added in 8.1.0, return type changed from boolean in 8.1.0 + * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371 */ public function insertIfNotExist($table, $input, array $compare = null);