fix: user:settings command when user is not available

If `ignore-missing-user` all sub commands work, except listing all settings
for a user like `occ user:settings --ignore-missing-user user core`.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2024-09-11 11:26:59 +02:00 committed by backportbot[bot]
parent f262fdf4b3
commit 48a13be4da

View file

@ -219,7 +219,7 @@ class Setting extends Base {
}
}
protected function getUserSettings($uid, $app) {
protected function getUserSettings(string $uid, string $app): array {
$settings = $this->config->getAllUserValues($uid);
if ($app !== '') {
if (isset($settings[$app])) {
@ -230,7 +230,10 @@ class Setting extends Base {
}
$user = $this->userManager->get($uid);
$settings['settings']['display_name'] = $user->getDisplayName();
if ($user !== null) {
// Only add the display name if the user exists
$settings['settings']['display_name'] = $user->getDisplayName();
}
return $settings;
}