summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-10-18 17:16:25 +0200
committerGitHub <noreply@github.com>2016-10-18 17:16:25 +0200
commitc55a737b2682ce2ba6a13d36fcf750a9ab66e562 (patch)
tree6cb76019879cc631dbcaaca52e165b92e77ede9c
parent0923d2665f516e5505340122bf0f2e1deca08825 (diff)
parent6c5f7d586e6bad7671587c61dbe3a260d098b57f (diff)
downloadnextcloud-server-c55a737b2682ce2ba6a13d36fcf750a9ab66e562.tar.gz
nextcloud-server-c55a737b2682ce2ba6a13d36fcf750a9ab66e562.zip
Merge pull request #1734 from nextcloud/setvalue_opt
AllConfig setUserValue opt
-rw-r--r--apps/encryption/tests/MigrationTest.php4
-rw-r--r--lib/private/AllConfig.php19
2 files changed, 23 insertions, 0 deletions
diff --git a/apps/encryption/tests/MigrationTest.php b/apps/encryption/tests/MigrationTest.php
index 868a1ad3922..595d7f12067 100644
--- a/apps/encryption/tests/MigrationTest.php
+++ b/apps/encryption/tests/MigrationTest.php
@@ -343,6 +343,10 @@ class MigrationTest extends \Test\TestCase {
unset($cache['files_encryption']);
$this->invokePrivate(\OC::$server->getAppConfig(), 'cache', [$cache]);
+ $cache = $this->invokePrivate($config, 'userCache');
+ unset($cache[self::TEST_ENCRYPTION_MIGRATION_USER1]);
+ $this->invokePrivate(\OC::$server->getAppConfig(), 'userCache', [$cache]);
+
// delete default values set by the encryption app during initialization
/** @var \OCP\IDBConnection $connection */
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index 52d77bf3f52..af26d30d8e9 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -215,6 +215,25 @@ class AllConfig implements \OCP\IConfig {
// TODO - FIXME
$this->fixDIInit();
+ if (isset($this->userCache[$userId][$appName][$key])) {
+ if ($this->userCache[$userId][$appName][$key] === (string)$value) {
+ return;
+ } else if ($preCondition !== null && $this->userCache[$userId][$appName][$key] !== (string)$preCondition) {
+ return;
+ } else {
+ $qb = $this->connection->getQueryBuilder();
+ $qb->update('preferences')
+ ->set('configvalue', $qb->createNamedParameter($value))
+ ->where($qb->expr()->eq('userid', $qb->createNamedParameter($userId)))
+ ->andWhere($qb->expr()->eq('appid', $qb->createNamedParameter($appName)))
+ ->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter($key)));
+ $qb->execute();
+
+ $this->userCache[$userId][$appName][$key] = $value;
+ return;
+ }
+ }
+
$preconditionArray = [];
if (isset($preCondition)) {
$preconditionArray = [