Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport/check groups exist before rendering workspaces/stable3.2/1057 #1058

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public function createWorkspace(string $spaceName,
throw new BadRequestException('spaceName must be provided');
}

if($this->workspaceCheck->containSpecialChar($spaceName)) {
throw new BadRequestException('Your Workspace name must not contain the following characters: ' . implode(" ", str_split(WorkspaceCheckService::CHARACTERS_SPECIAL)));
if ($this->workspaceCheck->containSpecialChar($spaceName)) {
throw new BadRequestException('Your Workspace name must not contain the following characters: ' . implode(' ', str_split(WorkspaceCheckService::CHARACTERS_SPECIAL)));
}

if ($this->workspaceCheck->isExist($spaceName)) {
Expand Down Expand Up @@ -196,8 +196,24 @@ public function findAll(): JSONResponse {
) : $workspace;

$gids = array_keys($space['groups'] ?? []);
$groups = array_map(fn ($gid) => $this->groupManager->get($gid), $gids);


$groups = [];

foreach ($gids as $gid) {
$group = $this->groupManager->get($gid);

if (is_null($group)) {
$this->logger->warning(
"Be careful, the $gid group is not exist in the oc_groups table."
. " But, it's present in the oc_group_folders_groups table."
. 'It necessary to recreate it with the occ command.'
);
continue;
}

$groups[] = $group;
}

$space['groups'] = GroupFormatter::formatGroups($groups);
$space['users'] = $this->workspaceService->addUsersInfo($space);

Expand Down Expand Up @@ -304,7 +320,7 @@ public function renameSpace(array|string $workspace,
}

if ($this->workspaceCheck->containSpecialChar($newSpaceName)) {
throw new BadRequestException('Your Workspace name must not contain the following characters: ' . implode(" ", str_split(WorkspaceCheckService::CHARACTERS_SPECIAL)));
throw new BadRequestException('Your Workspace name must not contain the following characters: ' . implode(' ', str_split(WorkspaceCheckService::CHARACTERS_SPECIAL)));
}

if ($newSpaceName === false ||
Expand Down
Loading