summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-11-15 22:14:27 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2016-11-16 18:52:49 +0100
commit2960b97fc728e9212c63f49cb46fa119853a4e26 (patch)
tree07d363d3b5a93d22a9f60fc64eb58b03095228dc /lib
parentcc8750ca30ba5d13ca59cc8c3ce87122a451829a (diff)
downloadnextcloud-server-2960b97fc728e9212c63f49cb46fa119853a4e26.tar.gz
nextcloud-server-2960b97fc728e9212c63f49cb46fa119853a4e26.zip
Don't update value if it is already set to the same value
* this PR makes sure to warm up the cache for that user * then the logic within the "if is in cache" code can be used to reduce needed queries * inspired by @andreas-p - https://github.com/nextcloud/server/pull/2128 Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/AllConfig.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index af26d30d8e9..cd1d5f69ac1 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -215,11 +215,14 @@ class AllConfig implements \OCP\IConfig {
// TODO - FIXME
$this->fixDIInit();
+ // warm up the cache to avoid updating the value if it is already set to this value before
+ $this->getUserValue($userId, $appName, $key);
+
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;
+ throw new PreConditionNotMetException();
} else {
$qb = $this->connection->getQueryBuilder();
$qb->update('preferences')