@@ -112,6 +112,9 @@ public function set(string $uid, array $settings, bool $writeDefaults = false) :
112112 if ($ value !== null && array_key_exists ($ name , $ this ->attrs )) {
113113 $ settings [$ name ] = $ value = $ this ->attrs [$ name ]['validate ' ]($ value );
114114 }
115+ if ($ name === 'notesPath ' && $ value !== null && (!$ writeDefaults || $ value === $ this ->getDefaultNotesPath ($ uid ))) {
116+ continue ;
117+ }
115118 $ default = is_callable ($ this ->attrs [$ name ]['default ' ]) ? $ this ->attrs [$ name ]['default ' ]($ uid ) : $ this ->attrs [$ name ]['default ' ];
116119 if (!$ writeDefaults && (!array_key_exists ($ name , $ this ->attrs )
117120 || $ value === null
@@ -149,18 +152,22 @@ public function getAll(string $uid, $saveInitial = false) : \stdClass {
149152 $ settings = $ this ->getSettingsFromDB ($ uid );
150153 // use default for empty settings
151154 $ toBeSaved = false ;
155+ $ toSaveNotesPath = false ;
152156 foreach ($ this ->attrs as $ name => $ attr ) {
153157 if (!property_exists ($ settings , $ name )) {
154158 $ defaultValue = $ attr ['default ' ];
155159 if (is_callable ($ defaultValue )) {
156160 $ settings ->{$ name } = $ defaultValue ($ uid );
157161 $ toBeSaved = $ saveInitial ;
162+ if ($ name === 'notesPath ' ) {
163+ $ toSaveNotesPath = true ;
164+ }
158165 } else {
159166 $ settings ->{$ name } = $ defaultValue ;
160167 }
161168 }
162169 }
163- if ($ toBeSaved ) {
170+ if ($ toSaveNotesPath || $ toBeSaved ) {
164171 $ this ->set ($ uid , (array )$ settings );
165172 }
166173 return $ settings ;
0 commit comments