Merge pull request #59719 from nextcloud/fix/visibilityNormalization

This commit is contained in:
Benjamin Gaussorgues 2026-04-20 17:29:28 +02:00 committed by GitHub
commit fca6085e0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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,
};
}
}