From 25d70bf77fd98a1f1c55ca7e55872d2ca73617f6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 13 Sep 2024 09:16:35 +0200 Subject: fix(config): Throw PreconditionException always when it didn't match Previously even when the precondition did not match, the call "passed" when the after value was the expected one. This however can lead to race conditions, duplicate code excutions and other things. Signed-off-by: Joas Schilling --- lib/private/AllConfig.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/private/AllConfig.php') diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 7a54de2b7bb..558b181050d 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -264,10 +264,10 @@ class AllConfig implements IConfig { $prevValue = $this->getUserValue($userId, $appName, $key, null); if ($prevValue !== null) { - if ($prevValue === (string)$value) { - return; - } elseif ($preCondition !== null && $prevValue !== (string)$preCondition) { + if ($preCondition !== null && $prevValue !== (string)$preCondition) { throw new PreConditionNotMetException(); + } elseif ($prevValue === (string)$value) { + return; } else { $qb = $this->connection->getQueryBuilder(); $qb->update('preferences') -- cgit v1.2.3