1717use OCA \Libresign \Service \SessionService ;
1818use OCP \AppFramework \Utility \ITimeFactory ;
1919use OCP \EventDispatcher \IEventDispatcher ;
20+ use OCP \Exceptions \AppConfigTypeConflictException ;
2021use OCP \Files \IRootFolder ;
2122use OCP \IAppConfig ;
2223use 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