diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 10e312b5c..d3e0eb13e 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -101,7 +101,7 @@ public function set(string $uid, array $settings) : void { $settings[$name] = $value = $this->attrs[$name]['validate']($value); } if (!array_key_exists($name, $this->attrs) - || empty($value) + || $value === null || $value === $this->attrs[$name]['default'] ) { unset($settings[$name]); @@ -123,7 +123,7 @@ public function getAll(string $uid) : \stdClass { // use default for empty settings $toBeSaved = false; foreach ($this->attrs as $name => $attr) { - if (!property_exists($settings, $name) || empty($settings->{$name})) { + if (!property_exists($settings, $name)) { $defaultValue = $attr['default']; if (is_callable($defaultValue)) { $settings->{$name} = $defaultValue($uid); diff --git a/src/components/AppSettings.vue b/src/components/AppSettings.vue index e34e074ea..c1259823f 100644 --- a/src/components/AppSettings.vue +++ b/src/components/AppSettings.vue @@ -9,7 +9,7 @@ v-model="settings.notesPath" type="text" name="notesPath" - :placeholder="t('notes', 'path to notes')" + :placeholder="t('notes', 'root directory')" @change="onChangeSettingsReload" > diff --git a/tests/api/APIv1Test.php b/tests/api/APIv1Test.php index c9e40268a..29bb60f23 100644 --- a/tests/api/APIv1Test.php +++ b/tests/api/APIv1Test.php @@ -181,6 +181,9 @@ public function testSettings(array $refNotes, \stdClass $settings) : void { ], (object)[ 'notesPath' => 'New-Test-Notes-Folder2', ], 'Update notesPath with path traversal check'); + $this->updateSettings($settings, (object)[ + 'notesPath' => '', + ], (object)[], 'Update notesPath with root directory'); $this->updateSettings($settings, (object)[ 'fileSuffix' => 'illegal value', ], (object)[