summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-05-11 16:05:30 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-05-11 16:05:30 +0200
commitafcec88c6f53512cebd2e3593ca47a6fee7cf886 (patch)
tree4abbb1c5a2d48ea27d0668b1c719bd7b72e5c682 /lib
parent90d8e4bc0081b28f50a427488f2b542de9b0d8d9 (diff)
parentdfed287dc02ba7b0fb8fe16542f9e7235eae9223 (diff)
downloadnextcloud-server-afcec88c6f53512cebd2e3593ca47a6fee7cf886.tar.gz
nextcloud-server-afcec88c6f53512cebd2e3593ca47a6fee7cf886.zip
Merge pull request #16234 from owncloud/issue-16206-fix-app-config-parallel-insert
Issue 16206 fix app config parallel insert
Diffstat (limited to 'lib')
-rw-r--r--lib/private/appconfig.php27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php
index a2095c571f3..37532616e1e 100644
--- a/lib/private/appconfig.php
+++ b/lib/private/appconfig.php
@@ -42,13 +42,14 @@
namespace OC;
-use \OC\DB\Connection;
+use OC\DB\Connection;
+use OCP\IAppConfig;
/**
* This class provides an easy way for apps to store config values in the
* database.
*/
-class AppConfig implements \OCP\IAppConfig {
+class AppConfig implements IAppConfig {
/**
* @var \OC\DB\Connection $conn
*/
@@ -64,7 +65,7 @@ class AppConfig implements \OCP\IAppConfig {
private $apps = null;
/**
- * @param \OC\DB\Connection $conn
+ * @param Connection $conn
*/
public function __construct(Connection $conn) {
$this->conn = $conn;
@@ -172,27 +173,31 @@ class AppConfig implements \OCP\IAppConfig {
}
/**
- * sets a value in the appconfig
+ * Sets a value. If the key did not exist before it will be created.
*
* @param string $app app
* @param string $key key
* @param string $value value
- *
- * Sets a value. If the key did not exist before it will be created.
+ * @return void
*/
public function setValue($app, $key, $value) {
+ $inserted = false;
// Does the key exist? no: insert, yes: update.
if (!$this->hasKey($app, $key)) {
- $data = array(
+ $inserted = (bool) $this->conn->insertIfNotExist('*PREFIX*appconfig', [
'appid' => $app,
'configkey' => $key,
'configvalue' => $value,
- );
- $this->conn->insert('*PREFIX*appconfig', $data);
- } else {
+ ], [
+ 'appid',
+ 'configkey',
+ ]);
+ }
+
+ if (!$inserted) {
$oldValue = $this->getValue($app, $key);
if($oldValue === strval($value)) {
- return true;
+ return;
}
$data = array(
'configvalue' => $value,