aboutsummaryrefslogtreecommitdiffstats
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
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>
-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')
r: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<?php

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
    echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
    exit(1);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitFiles_Sharing::getLoader();