Skip to content

Commit

Permalink
fix(controller): Check if the group already exist before rendering
Browse files Browse the repository at this point in the history
It's possible for a group not to exist, but still to be attached to a
groupfolder.
This change allows for this issue.
  • Loading branch information
zak39 committed Sep 9, 2024
1 parent a9d0e86 commit e2b0a63
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
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

0 comments on commit e2b0a63

Please sign in to comment.