From b0d30d4b47d1209ee38eb4ebc5ff7b0cd92d1ad4 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 25 Sep 2025 14:54:25 +0200 Subject: [PATCH] handle AppConfigTypeConflictException when getting/setting allow_multiple_user_backends Signed-off-by: Julien Veyssier --- lib/Service/SettingsService.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index e02d23516..dc06ba82c 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -11,20 +11,34 @@ namespace OCA\UserOIDC\Service; use OCA\UserOIDC\AppInfo\Application; +use OCP\Exceptions\AppConfigTypeConflictException; use OCP\IAppConfig; +use Psr\Log\LoggerInterface; class SettingsService { public function __construct( private IAppConfig $appConfig, + private LoggerInterface $logger, ) { } public function getAllowMultipleUserBackEnds(): bool { - return $this->appConfig->getValueString(Application::APP_ID, 'allow_multiple_user_backends', '1') === '1'; + try { + return $this->appConfig->getValueString(Application::APP_ID, 'allow_multiple_user_backends', '1') === '1'; + } catch (AppConfigTypeConflictException $e) { + $this->logger->warning('Incorrect app config type when getting "allow_multiple_user_backends"', ['exception' => $e]); + return true; + } } public function setAllowMultipleUserBackEnds(bool $value): void { - $this->appConfig->setValueString(Application::APP_ID, 'allow_multiple_user_backends', $value ? '1' : '0'); + try { + $this->appConfig->setValueString(Application::APP_ID, 'allow_multiple_user_backends', $value ? '1' : '0'); + } catch (AppConfigTypeConflictException $e) { + $this->logger->warning('Incorrect app config type when setting "allow_multiple_user_backends"', ['exception' => $e]); + $this->appConfig->deleteKey(Application::APP_ID, 'allow_multiple_user_backends'); + $this->appConfig->setValueString(Application::APP_ID, 'allow_multiple_user_backends', $value ? '1' : '0'); + } } }