Skip to content

Commit

Permalink
TASK: Remove obsolete REBASE_ERROR content stream state
Browse files Browse the repository at this point in the history
Via #4965 the status REBASE_ERROR is obsolete.
Instead of still using this status on replay we mimic the new logic:
> In case of a [rebase error}, reopen the old content stream and remove the newly created

Additionally, to not break `findContentStreams` when fetching all content streams we make sure that the streams with `REBASE_ERROR` are transformed to `NO_LONGER_IN_USE` so they can be cleaned up.

Related neos/neos-development-collection#5101
  • Loading branch information
mhsdesign committed Oct 17, 2024
1 parent 78d8d29 commit 1e281bc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/DoctrineDbalContentGraphProjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ public function setUp(): void
$this->dbal->getSchemaManager()->tablesExist([$legacyContentStreamTableName])
&& !$this->dbal->getSchemaManager()->tablesExist([$this->tableNames->contentStream()])
) {
$statements[] = 'INSERT INTO ' . $this->tableNames->contentStream() . ' (id, version, sourceContentStreamId, status, removed) SELECT contentStreamId AS id, version, sourceContentStreamId, state AS status, removed FROM ' . $legacyContentStreamTableName;
// special migration regarding content stream table:
// 1.) don't copy removed content streams as they would not be flagged but actually removed
// 2.) transform legacy `REBASE_ERROR` content streams into `NO_LONGER_IN_USE`, as they should be removed and wouldn't exist today as well. (We cannot reopen the content stream that was attempted to be rebased like we would today in the migration here, for that a replay must be executed see whenWorkspaceRebaseFailed)
$statements[] = 'INSERT INTO ' . $this->tableNames->contentStream() . ' (id, version, sourceContentStreamId, status) SELECT contentStreamId AS id, version, sourceContentStreamId, REPLACE(state, \'REBASE_ERROR\', \'NO_LONGER_IN_USE\') AS status FROM ' . $legacyContentStreamTableName . ' WHERE NOT removed = 1';
}
// /MIGRATION

Expand Down Expand Up @@ -733,8 +736,15 @@ private function whenWorkspaceBaseWorkspaceWasChanged(WorkspaceBaseWorkspaceWasC

private function whenWorkspaceRebaseFailed(WorkspaceRebaseFailed $event): void
{
// legacy handling:
// before https://github.com/neos/neos-development-collection/pull/4965 this event was emitted and set the content stream status to `REBASE_ERROR`
// instead of setting the error state on replay for old events we make it behave like if the rebase had failed today:
// 4.E) In case of a [rebase error}, reopen the old content stream and remove the newly created
// The ContentStreamWasReopened event would be emitted with `IN_USE_BY_WORKSPACE` (because that _must_ be the previous state as a workspace was rebased)
$this->whenContentStreamWasReopened(new ContentStreamWasReopened($event->sourceContentStreamId, ContentStreamStatus::IN_USE_BY_WORKSPACE));
$this->whenContentStreamWasRemoved(new ContentStreamWasRemoved($event->candidateContentStreamId));

$this->markWorkspaceAsOutdatedConflict($event->workspaceName);
$this->updateContentStreamStatus($event->candidateContentStreamId, ContentStreamStatus::REBASE_ERROR);
}

private function whenWorkspaceWasCreated(WorkspaceWasCreated $event): void
Expand Down

0 comments on commit 1e281bc

Please sign in to comment.