summaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-12-03 21:31:29 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-12-08 22:33:36 +0100
commitaf91ee97c981d32bcd531e71d31e16f1232c44ce (patch)
treea38253e8311aa0056f90af6adc89d9b791d1dc00 /lib/private/legacy
parentf0b10324caf1637d8ad5a9ed94dfed084f65407d (diff)
downloadnextcloud-server-af91ee97c981d32bcd531e71d31e16f1232c44ce.tar.gz
nextcloud-server-af91ee97c981d32bcd531e71d31e16f1232c44ce.zip
introduce preCondition for setUserValue to provide atomic check-and-update
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/preferences.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/private/legacy/preferences.php b/lib/private/legacy/preferences.php
index 28af124db32..907aafbc915 100644
--- a/lib/private/legacy/preferences.php
+++ b/lib/private/legacy/preferences.php
@@ -70,10 +70,12 @@ class OC_Preferences{
* will be added automagically.
*/
public static function setValue( $user, $app, $key, $value, $preCondition = null ) {
- return \OC::$server->getConfig()->setUserValue($user, $app, $key, $value);
-
- // TODO maybe catch exceptions and then return false
- return true;
+ try {
+ \OC::$server->getConfig()->setUserValue($user, $app, $key, $value, $preCondition);
+ return true;
+ } catch(\OCP\PreConditionNotMetException $e) {
+ return false;
+ }
}
/**