Skip to content

Commit 6277b75

Browse files
committed
fix(settings): Check all values first, then apply them
Signed-off-by: Marcel Klehr <[email protected]>
1 parent d382e2c commit 6277b75

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

apps/settings/lib/Controller/AISettingsController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,20 @@ public function update($settings) {
4444
continue;
4545
}
4646
try {
47-
$value = json_encode($settings[$key], flags: \JSON_THROW_ON_ERROR);
47+
$settings[$key] = json_encode($settings[$key], flags: \JSON_THROW_ON_ERROR);
4848
} catch (\JsonException) {
4949
return new DataResponse(['error' => "Setting value for '$key' must be JSON-compatible"], Http::STATUS_BAD_REQUEST);
5050
}
51-
$changed = $this->appConfig->setValueString('core', $key, $value, lazy: in_array($key, \OC\TaskProcessing\Manager::LAZY_CONFIG_KEYS, true));
51+
}
52+
foreach ($keys as $key) {
53+
if (!isset($settings[$key])) {
54+
continue;
55+
}
56+
$changed = $this->appConfig->setValueString('core', $key, $settings[$key], lazy: in_array($key, \OC\TaskProcessing\Manager::LAZY_CONFIG_KEYS, true));
5257
if ($changed) {
5358
$this->eventDispatcher->dispatchTyped(new CriticalActionPerformedEvent(
5459
'AI configuration was changed by user %s: %s was set to %s',
55-
[$this->userId, $key, $value]
60+
[$this->userId, $key, $settings[$key]]
5661
));
5762
}
5863
}

0 commit comments

Comments
 (0)