Skip to content

Commit

Permalink
BUGFIX: Allow managing personal workspaces without owners
Browse files Browse the repository at this point in the history
Under certain circumstances personal workspaces exist
without an owner. It was impossible to delete or modify those
workspaces.
This changes makes it possible for admins to delete them.
  • Loading branch information
Sebobo committed May 27, 2024
1 parent ee01b75 commit e869589
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Classes/Controller/WorkspacesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function deleteAction(Workspace $workspace): void
/** @var Workspace[] $rebasedWorkspaces */
$rebasedWorkspaces = [];

if ($workspace->isPersonalWorkspace()) {
if ($workspace->isPersonalWorkspace() && $workspace->getOwner() !== null) {
$this->addFlashMessage(
$this->translateById('message.workspaceIsPersonal', ['workspaceName' => $workspace->getTitle()]),
'',
Expand Down Expand Up @@ -301,7 +301,7 @@ protected function getWorkspaceInfo(Workspace $workspace): array
'isInternal' => $workspace->isInternalWorkspace(),
'isStale' => $isStale,
'canPublish' => $this->userService->currentUserCanPublishToWorkspace($workspace),
'canManage' => $this->userService->currentUserCanManageWorkspace($workspace),
'canManage' => $this->canManageWorkspace($workspace),
'dependentWorkspacesCount' => count($this->workspaceRepository->findByBaseWorkspace($workspace)),
'creator' => $creator ? [
'id' => $creator,
Expand Down Expand Up @@ -650,4 +650,13 @@ protected function validateWorkspaceChain(Workspace $workspace): bool
return true;
}

protected function canManageWorkspace(Workspace $workspace): bool
{
// Workaround to make personal workspaces with missing owners manageable
if ($workspace->isPersonalWorkspace() && !$workspace->getOwner()) {
return $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.Module.Management.Workspaces.ManageAllPrivateWorkspaces');
}
return $this->userService->currentUserCanManageWorkspace($workspace);
}

}

0 comments on commit e869589

Please sign in to comment.