Skip to content

Commit 3725217

Browse files
authored
Merge pull request #348 from nextcloud/typeconflictexception
Fix type conflict exception for user config
2 parents 6f4b30a + b4d21a9 commit 3725217

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/Controller/ConfigController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class ConfigController extends Controller {
4242
public const CALENDAR_SCOPE = 'https://www.googleapis.com/auth/calendar.readonly';
4343
public const CALENDAR_EVENTS_SCOPE = 'https://www.googleapis.com/auth/calendar.events.readonly';
4444

45+
public const INT_CONFIGS = ['nb_imported_files', 'drive_imported_size', 'last_drive_import_timestamp', 'drive_import_job_last_start'];
46+
4547
public function __construct(
4648
string $appName,
4749
IRequest $request,
@@ -72,7 +74,13 @@ public function setConfig(array $values): DataResponse {
7274
return new DataResponse([], Http::STATUS_BAD_REQUEST);
7375
}
7476
foreach ($values as $key => $value) {
75-
$this->userConfig->setValueString($this->userId, Application::APP_ID, $key, $value, lazy: true);
77+
if (in_array($key, self::INT_CONFIGS, true)) {
78+
$intValue = (int)$value;
79+
$this->userConfig->setValueInt($this->userId, Application::APP_ID, $key, $intValue, lazy: true);
80+
} else {
81+
$value = (string)$value;
82+
$this->userConfig->setValueString($this->userId, Application::APP_ID, $key, $value, lazy: true);
83+
}
7684
}
7785
$result = [];
7886

0 commit comments

Comments
 (0)