|
|
|
@ -67,7 +67,6 @@ class Database extends ABackend implements
|
|
|
|
public function createGroup(string $name): ?string {
|
|
|
|
public function createGroup(string $name): ?string {
|
|
|
|
$this->fixDI();
|
|
|
|
$this->fixDI();
|
|
|
|
|
|
|
|
|
|
|
|
$name = $this->sanitizeGroupName($name);
|
|
|
|
|
|
|
|
$gid = $this->computeGid($name);
|
|
|
|
$gid = $this->computeGid($name);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Add group
|
|
|
|
// Add group
|
|
|
|
@ -587,21 +586,12 @@ class Database extends ABackend implements
|
|
|
|
return 'Database';
|
|
|
|
return 'Database';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Merge any white spaces to a single space in group name, then trim it.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private function sanitizeGroupName(string $displayName): string {
|
|
|
|
|
|
|
|
$cleanedDisplayName = preg_replace('/\s+/', ' ', $displayName);
|
|
|
|
|
|
|
|
return trim($cleanedDisplayName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Compute group ID from display name (GIDs are limited to 64 characters in database)
|
|
|
|
* Compute group ID from display name (GIDs are limited to 64 characters in database)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function computeGid(string $displayName): string {
|
|
|
|
private function computeGid(string $displayName): string {
|
|
|
|
$displayNameWithoutWhitespace = preg_replace('/\s+/', '_', $displayName);
|
|
|
|
return mb_strlen($displayName) > 64
|
|
|
|
return mb_strlen($displayNameWithoutWhitespace) > 64
|
|
|
|
? hash('sha256', $displayName)
|
|
|
|
? hash('sha256', $displayNameWithoutWhitespace)
|
|
|
|
: $displayName;
|
|
|
|
: $displayNameWithoutWhitespace;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|