aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJana Peper <jana.peper@nextcloud.com>2024-12-17 17:00:07 +0100
committerjanepie <49834966+janepie@users.noreply.github.com>2024-12-18 18:32:34 +0100
commitee31b3bbe525d1499d7e64962fd0d3521e23a358 (patch)
tree0c9c576d043f97402fef8cb5c34bcb283f994631 /core
parentd87302c651dfb18d80856c07d7a16e9c97d68bb0 (diff)
downloadnextcloud-server-ee31b3bbe525d1499d7e64962fd0d3521e23a358.tar.gz
nextcloud-server-ee31b3bbe525d1499d7e64962fd0d3521e23a358.zip
fix: error handling for wrong json values
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
Diffstat (limited to 'core')
-rw-r--r--core/Command/TaskProcessing/EnabledCommand.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/core/Command/TaskProcessing/EnabledCommand.php b/core/Command/TaskProcessing/EnabledCommand.php
index 44a5cdef256..b382de12a81 100644
--- a/core/Command/TaskProcessing/EnabledCommand.php
+++ b/core/Command/TaskProcessing/EnabledCommand.php
@@ -41,16 +41,21 @@ class EnabledCommand extends Base {
$enabled = (bool)$input->getArgument('enabled');
$taskType = $input->getArgument('task-type-id');
$json = $this->config->getAppValue('core', 'ai.taskprocessing_type_preferences');
- if ($json === '') {
- $taskTypeSettings = [];
- } else {
- $taskTypeSettings = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
+ try {
+ if ($json === '') {
+ $taskTypeSettings = [];
+ } else {
+ $taskTypeSettings = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
+ }
+
+ $taskTypeSettings[$taskType] = $enabled;
+
+ $this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskTypeSettings));
+ $this->writeArrayInOutputFormat($input, $output, $taskTypeSettings);
+ return 0;
+ } catch (\JsonException $e) {
+ throw new \JsonException('Error in TaskType DB entry');
}
- $taskTypeSettings[$taskType] = $enabled;
-
- $this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskTypeSettings));
- $this->writeArrayInOutputFormat($input, $output, $taskTypeSettings);
- return 0;
}
}