diff options
Diffstat (limited to 'core/Command/TaskProcessing')
-rw-r--r-- | core/Command/TaskProcessing/EnabledCommand.php | 23 |
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; } } |