Skip to content

Commit 286c987

Browse files
committed
fix: load legacy identify methods config
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 6f627ca commit 286c987

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

lib/Service/IdentifyMethod/IdentifyService.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OCA\Libresign\Service\SessionService;
1818
use OCP\AppFramework\Utility\ITimeFactory;
1919
use OCP\EventDispatcher\IEventDispatcher;
20+
use OCP\Exceptions\AppConfigTypeConflictException;
2021
use OCP\Files\IRootFolder;
2122
use OCP\IAppConfig;
2223
use OCP\IL10N;
@@ -130,8 +131,21 @@ public function getSavedSettings(): array {
130131
return $this->savedSettings;
131132
}
132133

134+
$this->getAppConfig()->clearCache(true);
135+
133136
try {
134137
$this->savedSettings = $this->getAppConfig()->getValueArray(Application::APP_ID, 'identify_methods', []);
138+
} catch (AppConfigTypeConflictException $exception) {
139+
$legacySettings = $this->getLegacySavedSettings();
140+
if ($legacySettings !== null) {
141+
$this->savedSettings = $legacySettings;
142+
return $this->savedSettings;
143+
}
144+
145+
$this->logger->warning('Invalid identify_methods app config; falling back to defaults.', [
146+
'exception' => $exception,
147+
]);
148+
$this->savedSettings = [];
135149
} catch (\TypeError $exception) {
136150
$this->logger->warning('Invalid identify_methods app config; falling back to defaults.', [
137151
'exception' => $exception,
@@ -142,6 +156,17 @@ public function getSavedSettings(): array {
142156
return $this->savedSettings;
143157
}
144158

159+
private function getLegacySavedSettings(): ?array {
160+
try {
161+
$legacyValue = $this->getAppConfig()->getValueString(Application::APP_ID, 'identify_methods', '');
162+
} catch (AppConfigTypeConflictException|\TypeError) {
163+
return null;
164+
}
165+
166+
$decoded = json_decode($legacyValue, true);
167+
return is_array($decoded) ? $decoded : null;
168+
}
169+
145170
public function getEventDispatcher(): IEventDispatcher {
146171
return $this->eventDispatcher;
147172
}

0 commit comments

Comments
 (0)