Skip to content

Commit 58d3f1c

Browse files
committed
fix: tolerate invalid identify methods config
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 90b51c9 commit 58d3f1c

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

lib/Service/IdentifyMethod/IdentifyService.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use Psr\Log\LoggerInterface;
2727

2828
class IdentifyService {
29-
private array $savedSettings = [];
29+
private ?array $savedSettings = null;
3030
public function __construct(
3131
private IdentifyMethodMapper $identifyMethodMapper,
3232
private SessionService $sessionService,
@@ -126,10 +126,20 @@ private function refreshIdFromDatabaseIfNecessary(IdentifyMethod $identifyMethod
126126
}
127127

128128
public function getSavedSettings(): array {
129-
if (!empty($this->savedSettings)) {
129+
if ($this->savedSettings !== null) {
130130
return $this->savedSettings;
131131
}
132-
return $this->getAppConfig()->getValueArray(Application::APP_ID, 'identify_methods', []);
132+
133+
try {
134+
$this->savedSettings = $this->getAppConfig()->getValueArray(Application::APP_ID, 'identify_methods', []);
135+
} catch (\TypeError $exception) {
136+
$this->logger->warning('Invalid identify_methods app config; falling back to defaults.', [
137+
'exception' => $exception,
138+
]);
139+
$this->savedSettings = [];
140+
}
141+
142+
return $this->savedSettings;
133143
}
134144

135145
public function getEventDispatcher(): IEventDispatcher {

0 commit comments

Comments
 (0)