Skip to content

Commit

Permalink
Merge pull request #1058 from arawa/backport/check-groups-exist-befor…
Browse files Browse the repository at this point in the history
…e-rendering-workspaces/stable3.2/1057

Backport/check groups exist before rendering workspaces/stable3.2/1057
  • Loading branch information
zak39 authored Sep 9, 2024
2 parents a9d0e86 + cd9faff commit b29440b
Showing 1 changed file with 21 additions and 5 deletions.
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

0 comments on commit b29440b

Please sign in to comment.