Skip to content

Commit

Permalink
TASK: Revert special code path from partial to full publish
Browse files Browse the repository at this point in the history
Reverts d2d9faa partially

Initially this change was done to fix neos#5303
But that was a hoax see neos#5303 (comment)

we always emit the `WorkspaceWasPublished` event and this just simplifies the code-path again.

For the discard all case, the code is stil a little easier to read _with_ the condition.
  • Loading branch information
mhsdesign committed Dec 9, 2024
1 parent ec01723 commit 3d572c8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ Feature: Discard individual nodes (basics)
| newContentStreamId | "user-cs-identifier-new" |
Then I expect the content stream "user-cs-identifier" to not exist
Then I expect exactly 2 events to be published on stream with prefix "Workspace:user-test"
And event at index 1 is of type "WorkspaceWasDiscarded" with payload:
| Key | Expected |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier-new" |
| previousContentStreamId | "user-cs-identifier" |
When I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "sir-david-nodenborough" to lead to node user-cs-identifier-new;sir-david-nodenborough;{}
And I expect this node to have the following properties:
Expand Down Expand Up @@ -159,7 +166,6 @@ Feature: Discard individual nodes (basics)
| nodesToDiscard | ["sir-david-nodenborough", "nody-mc-nodeface", "sir-nodeward-nodington-iii"] |
| newContentStreamId | "user-cs-identifier-new" |
# when discarding all nodes we expect a full discard via WorkspaceWasDiscarded
Then I expect exactly 2 events to be published on stream with prefix "Workspace:user-test"
And event at index 1 is of type "WorkspaceWasDiscarded" with payload:
| Key | Expected |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ Feature: Individual node publication
| nodesToPublish | ["sir-david-nodenborough"] |
| contentStreamIdForRemainingPart | "user-cs-identifier-remaining" |

Then I expect exactly 2 events to be published on stream with prefix "Workspace:user-test"
And event at index 1 is of type "WorkspaceWasPublished" with payload:
| Key | Expected |
| sourceWorkspaceName | "user-test" |
| targetWorkspaceName | "live" |
| newSourceContentStreamId | "user-cs-identifier-remaining" |
| previousSourceContentStreamId | "user-cs-identifier" |

And I am in workspace "live"

Then I expect a node identified by cs-identifier;sir-david-nodenborough;{} to exist in the content graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ Feature: Publishing individual nodes (basics)
| nodesToPublish | ["sir-david-nodenborough", "nody-mc-nodeface", "sir-nodeward-nodington-iii"] |
| contentStreamIdForRemainingPart | "user-cs-identifier-remaining" |
# when publishing all nodes we expect a full discard via WorkspaceWasPublished
Then I expect exactly 2 events to be published on stream with prefix "Workspace:user-test"
And event at index 1 is of type "WorkspaceWasPublished" with payload:
| Key | Expected |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,6 @@ private function handlePublishWorkspace(
$workspaceContentStreamVersion
);

yield from $this->publishWorkspace(
$workspace,
$baseWorkspace,
$baseWorkspaceContentStreamVersion,
$command->newContentStreamId,
$rebaseableCommands
);
}

/**
* Note that the workspaces content stream must be closed beforehand.
* It will be reopened here in case of error.
*/
private function publishWorkspace(
Workspace $workspace,
Workspace $baseWorkspace,
Version $baseWorkspaceContentStreamVersion,
ContentStreamId $newContentStreamId,
RebaseableCommands $rebaseableCommands
): \Generator {
$commandSimulator = $this->commandSimulatorFactory->createSimulatorForWorkspace($baseWorkspace->workspaceName);

$commandSimulator->run(
Expand Down Expand Up @@ -267,7 +247,7 @@ static function ($handle) use ($rebaseableCommands): void {
}

yield $this->forkContentStream(
$newContentStreamId,
$command->newContentStreamId,
$baseWorkspace->currentContentStreamId,
Version::fromInteger($baseWorkspaceContentStreamVersion->value + $eventsOfWorkspaceToPublish->count())
);
Expand All @@ -278,7 +258,7 @@ static function ($handle) use ($rebaseableCommands): void {
new WorkspaceWasPublished(
$workspace->workspaceName,
$baseWorkspace->workspaceName,
$newContentStreamId,
$command->newContentStreamId,
$workspace->currentContentStreamId,
)
),
Expand Down Expand Up @@ -475,18 +455,6 @@ private function handlePublishIndividualNodesFromWorkspace(
$workspaceContentStreamVersion
);

if ($remainingCommands->isEmpty()) {
// do a full publish, this is simpler for the projections to handle
yield from $this->publishWorkspace(
$workspace,
$baseWorkspace,
$baseWorkspaceContentStreamVersion,
$command->contentStreamIdForRemainingPart,
$matchingCommands
);
return;
}

$commandSimulator = $this->commandSimulatorFactory->createSimulatorForWorkspace($baseWorkspace->workspaceName);

$highestSequenceNumberForMatching = $commandSimulator->run(
Expand Down

0 comments on commit 3d572c8

Please sign in to comment.