Skip to content

Commit

Permalink
TASK: Remove legacy workspace state UPDATE logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 17, 2024
1 parent c22a4ac commit b2c53f8
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ private function whenWorkspaceBaseWorkspaceWasChanged(WorkspaceBaseWorkspaceWasC

private function whenWorkspaceRebaseFailed(WorkspaceRebaseFailed $event): void
{
$this->markWorkspaceAsOutdatedConflict($event->workspaceName);
$this->updateContentStreamStatus($event->candidateContentStreamId, ContentStreamStatus::REBASE_ERROR);
}

Expand All @@ -748,8 +747,6 @@ private function whenWorkspaceWasCreated(WorkspaceWasCreated $event): void
private function whenWorkspaceWasDiscarded(WorkspaceWasDiscarded $event): void
{
$this->updateWorkspaceContentStreamId($event->workspaceName, $event->newContentStreamId);
$this->markWorkspaceAsOutdated($event->workspaceName);
$this->markDependentWorkspacesAsOutdated($event->workspaceName);

// the new content stream is in use now
$this->updateContentStreamStatus($event->newContentStreamId, ContentStreamStatus::IN_USE_BY_WORKSPACE);
Expand All @@ -760,7 +757,6 @@ private function whenWorkspaceWasDiscarded(WorkspaceWasDiscarded $event): void
private function whenWorkspaceWasPartiallyDiscarded(WorkspaceWasPartiallyDiscarded $event): void
{
$this->updateWorkspaceContentStreamId($event->workspaceName, $event->newContentStreamId);
$this->markDependentWorkspacesAsOutdated($event->workspaceName);

// the new content stream is in use now
$this->updateContentStreamStatus($event->newContentStreamId, ContentStreamStatus::IN_USE_BY_WORKSPACE);
Expand All @@ -773,12 +769,6 @@ private function whenWorkspaceWasPartiallyPublished(WorkspaceWasPartiallyPublish
{
// TODO: How do we test this method? – It's hard to design a BDD testcase that fails if this method is commented out...
$this->updateWorkspaceContentStreamId($event->sourceWorkspaceName, $event->newSourceContentStreamId);
$this->markDependentWorkspacesAsOutdated($event->targetWorkspaceName);

// NASTY: we need to set the source workspace name as non-outdated; as it has been made up-to-date again.
$this->markWorkspaceAsUpToDate($event->sourceWorkspaceName);

$this->markDependentWorkspacesAsOutdated($event->sourceWorkspaceName);

// the new content stream is in use now
$this->updateContentStreamStatus($event->newSourceContentStreamId, ContentStreamStatus::IN_USE_BY_WORKSPACE);
Expand All @@ -791,12 +781,6 @@ private function whenWorkspaceWasPublished(WorkspaceWasPublished $event): void
{
// TODO: How do we test this method? – It's hard to design a BDD testcase that fails if this method is commented out...
$this->updateWorkspaceContentStreamId($event->sourceWorkspaceName, $event->newSourceContentStreamId);
$this->markDependentWorkspacesAsOutdated($event->targetWorkspaceName);

// NASTY: we need to set the source workspace name as non-outdated; as it has been made up-to-date again.
$this->markWorkspaceAsUpToDate($event->sourceWorkspaceName);

$this->markDependentWorkspacesAsOutdated($event->sourceWorkspaceName);

// the new content stream is in use now
$this->updateContentStreamStatus($event->newSourceContentStreamId, ContentStreamStatus::IN_USE_BY_WORKSPACE);
Expand All @@ -808,10 +792,6 @@ private function whenWorkspaceWasPublished(WorkspaceWasPublished $event): void
private function whenWorkspaceWasRebased(WorkspaceWasRebased $event): void
{
$this->updateWorkspaceContentStreamId($event->workspaceName, $event->newContentStreamId);
$this->markDependentWorkspacesAsOutdated($event->workspaceName);

// When the rebase is successful, we can set the status of the workspace back to UP_TO_DATE.
$this->markWorkspaceAsUpToDate($event->workspaceName);

// the new content stream is in use now
$this->updateContentStreamStatus($event->newContentStreamId, ContentStreamStatus::IN_USE_BY_WORKSPACE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ private function createWorkspaceTable(): Table
DbalSchemaFactory::columnForWorkspaceName('name')->setNotnull(true),
DbalSchemaFactory::columnForWorkspaceName('baseWorkspaceName')->setNotnull(false),
DbalSchemaFactory::columnForContentStreamId('currentContentStreamId')->setNotNull(true),
(new Column('status', self::type(Types::BINARY)))->setLength(20)->setNotnull(false),
]);

return $workspaceTable->setPrimaryKey(['name']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\Feature;

use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceStatus;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

Expand All @@ -20,8 +19,7 @@ private function createWorkspace(WorkspaceName $workspaceName, ?WorkspaceName $b
$this->dbal->insert($this->tableNames->workspace(), [
'name' => $workspaceName->value,
'baseWorkspaceName' => $baseWorkspaceName?->value,
'currentContentStreamId' => $contentStreamId->value,
'status' => WorkspaceStatus::UP_TO_DATE->value
'currentContentStreamId' => $contentStreamId->value
]);
}

Expand Down Expand Up @@ -55,58 +53,4 @@ private function updateWorkspaceContentStreamId(
'name' => $workspaceName->value
]);
}

private function markWorkspaceAsUpToDate(WorkspaceName $workspaceName): void
{
$this->dbal->executeStatement('
UPDATE ' . $this->tableNames->workspace() . '
SET status = :upToDate
WHERE
name = :workspaceName
', [
'upToDate' => WorkspaceStatus::UP_TO_DATE->value,
'workspaceName' => $workspaceName->value
]);
}

private function markDependentWorkspacesAsOutdated(WorkspaceName $baseWorkspaceName): void
{
$this->dbal->executeStatement('
UPDATE ' . $this->tableNames->workspace() . '
SET status = :outdated
WHERE
baseWorkspaceName = :baseWorkspaceName
', [
'outdated' => WorkspaceStatus::OUTDATED->value,
'baseWorkspaceName' => $baseWorkspaceName->value
]);
}

private function markWorkspaceAsOutdated(WorkspaceName $workspaceName): void
{
$this->dbal->executeStatement('
UPDATE ' . $this->tableNames->workspace() . '
SET
status = :outdated
WHERE
name = :workspaceName
', [
'outdated' => WorkspaceStatus::OUTDATED->value,
'workspaceName' => $workspaceName->value
]);
}

private function markWorkspaceAsOutdatedConflict(WorkspaceName $workspaceName): void
{
$this->dbal->executeStatement('
UPDATE ' . $this->tableNames->workspace() . '
SET
status = :outdatedConflict
WHERE
name = :workspaceName
', [
'outdatedConflict' => WorkspaceStatus::OUTDATED_CONFLICT->value,
'workspaceName' => $workspaceName->value
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@ enum WorkspaceStatus: string implements \JsonSerializable
*/
case OUTDATED = 'OUTDATED';

/**
* CONFLICT Example:
*
* CONFLICT is a special case of OUTDATED, but then an error happens during the rebasing.
*
* Workspace Review <----------------------------------- Workspace User-Foo
* | . |
* Content Stream A2 (current) <-- Content Stream B2 (rebasing) |
* Content Stream B1
*/
case OUTDATED_CONFLICT = 'OUTDATED_CONFLICT';

public function equals(self $other): bool
{
return $this->value === $other->value;
Expand Down

0 comments on commit b2c53f8

Please sign in to comment.