Skip to content

Commit

Permalink
Merge pull request #5313 from neos/bugfix/pruneRoleAssignmentsAndWork…
Browse files Browse the repository at this point in the history
…spaceMetadataWithCr-follow-up

Follow-up to #5306
  • Loading branch information
bwaidelich authored Oct 22, 2024
2 parents 7c5ad8c + f05917a commit f7aaa60
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Neos.Neos/Classes/Command/CrCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public function pruneCommand(string $contentRepository = 'default', bool $force
$this->projectionServiceFactory
);

// remove the workspace metadata and roles for this cr
$this->workspaceService->pruneRoleAsssignments($contentRepositoryId);
// remove the workspace metadata and role assignments for this cr
$this->workspaceService->pruneRoleAssignments($contentRepositoryId);
$this->workspaceService->pruneWorkspaceMetadata($contentRepositoryId);

// reset the events table
Expand Down
50 changes: 28 additions & 22 deletions Neos.Neos/Classes/Domain/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,34 @@ public function getUniqueWorkspaceName(ContentRepositoryId $contentRepositoryId,
throw new \RuntimeException(sprintf('Failed to find unique workspace name for "%s" after %d attempts.', $candidate, $attempt - 1), 1725975479);
}

/**
* Removes all workspace metadata records for the specified content repository id
*/
public function pruneWorkspaceMetadata(ContentRepositoryId $contentRepositoryId): void
{
try {
$this->dbal->delete(self::TABLE_NAME_WORKSPACE_METADATA, [
'content_repository_id' => $contentRepositoryId->value,
]);
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to prune workspace metadata Content Repository "%s": %s', $contentRepositoryId->value, $e->getMessage()), 1729512100, $e);
}
}

/**
* Removes all workspace role assignments for the specified content repository id
*/
public function pruneRoleAssignments(ContentRepositoryId $contentRepositoryId): void
{
try {
$this->dbal->delete(self::TABLE_NAME_WORKSPACE_ROLE, [
'content_repository_id' => $contentRepositoryId->value,
]);
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to prune workspace roles for Content Repository "%s": %s', $contentRepositoryId->value, $e->getMessage()), 1729512142, $e);
}
}

// ------------------

private function loadWorkspaceMetadata(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName): ?WorkspaceMetadata
Expand Down Expand Up @@ -382,28 +410,6 @@ private function updateWorkspaceMetadata(ContentRepositoryId $contentRepositoryI
}
}

public function pruneWorkspaceMetadata(ContentRepositoryId $contentRepositoryId): void
{
try {
$this->dbal->delete(self::TABLE_NAME_WORKSPACE_METADATA, [
'content_repository_id' => $contentRepositoryId->value,
]);
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to prune workspace metadata Content Repository "%s": %s', $contentRepositoryId->value, $e->getMessage()), 1729512100, $e);
}
}

public function pruneRoleAsssignments(ContentRepositoryId $contentRepositoryId): void
{
try {
$this->dbal->delete(self::TABLE_NAME_WORKSPACE_ROLE, [
'content_repository_id' => $contentRepositoryId->value,
]);
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to prune workspace roles for Content Repository "%s": %s', $contentRepositoryId->value, $e->getMessage()), 1729512142, $e);
}
}

private function createWorkspace(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, WorkspaceTitle $title, WorkspaceDescription $description, WorkspaceName $baseWorkspaceName, UserId|null $ownerId, WorkspaceClassification $classification): void
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
Expand Down

0 comments on commit f7aaa60

Please sign in to comment.