fix(profile): normalize profile visibility

Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
This commit is contained in:
Benjamin Gaussorgues 2026-03-26 16:30:44 +01:00 committed by backportbot[bot]
parent 0c98c47940
commit affe49d87c

View file

@ -11,6 +11,7 @@ namespace OC\Core\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
use OCP\Profile\IProfileManager;
use OCP\Profile\ParameterDoesNotExistException;
use function json_decode;
use function json_encode;
@ -68,7 +69,7 @@ class ProfileConfig extends Entity implements JsonSerializable {
foreach ($visibilityMap as $paramId => $visibility) {
$config[$paramId] = array_merge(
$config[$paramId] ?: [],
['visibility' => $visibility],
['visibility' => $this->normalizeVisibility($visibility)],
);
}
@ -103,4 +104,12 @@ class ProfileConfig extends Entity implements JsonSerializable {
'config' => $this->getConfigArray(),
];
}
private function normalizeVisibility(string $visibility): string {
return match(strtolower($visibility)) {
IProfileManager::VISIBILITY_SHOW => IProfileManager::VISIBILITY_SHOW,
IProfileManager::VISIBILITY_SHOW_USERS_ONLY => IProfileManager::VISIBILITY_SHOW_USERS_ONLY,
default => IProfileManager::VISIBILITY_HIDE,
};
}
}