Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Use proper version checks where applicable #5456

Open
wants to merge 1 commit into
base: 9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\ContentDimensionZookeeper;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\DimensionSpace\Exception\DimensionSpacePointIsNoSpecialization;
use Neos\ContentRepository\Core\DimensionSpace\Exception\DimensionSpacePointNotFound;
use Neos\ContentRepository\Core\DimensionSpace\InterDimensionalVariationGraph;
use Neos\ContentRepository\Core\DimensionSpace\VariantType;
use Neos\ContentRepository\Core\EventStore\Events;
use Neos\ContentRepository\Core\EventStore\EventsToPublish;
use Neos\ContentRepository\Core\Feature\Common\ConstraintChecks;
use Neos\ContentRepository\Core\Feature\Common\RebasableToOtherWorkspaceInterface;
use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Command\AddDimensionShineThrough;
Expand All @@ -34,6 +36,7 @@
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Event\DimensionSpacePointWasMoved;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Exception\DimensionSpacePointAlreadyExists;
use Neos\ContentRepository\Core\Feature\RebaseableCommand;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\EventStore\Model\EventStream\ExpectedVersion;
Expand Down Expand Up @@ -68,6 +71,7 @@ private function handleMoveDimensionSpacePoint(
CommandHandlingDependencies $commandHandlingDependencies
): EventsToPublish {
$contentGraph = $commandHandlingDependencies->getContentGraph($command->workspaceName);
$expectedVersion = ExpectedVersion::fromVersion($commandHandlingDependencies->getContentStreamVersion($contentGraph->getContentStreamId()));
$streamName = ContentStreamEventStreamName::fromContentStreamId($contentGraph->getContentStreamId())
->getEventStreamName();

Expand All @@ -90,7 +94,7 @@ private function handleMoveDimensionSpacePoint(
),
)
),
ExpectedVersion::ANY()
$expectedVersion
);
}

Expand All @@ -99,6 +103,7 @@ private function handleAddDimensionShineThrough(
CommandHandlingDependencies $commandHandlingDependencies
): EventsToPublish {
$contentGraph = $commandHandlingDependencies->getContentGraph($command->workspaceName);
$expectedVersion = ExpectedVersion::fromVersion($commandHandlingDependencies->getContentStreamVersion($contentGraph->getContentStreamId()));
$streamName = ContentStreamEventStreamName::fromContentStreamId($contentGraph->getContentStreamId())
->getEventStreamName();

Expand All @@ -123,7 +128,7 @@ private function handleAddDimensionShineThrough(
)
)
),
ExpectedVersion::ANY()
$expectedVersion
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ abstract protected function getInterDimensionalVariationGraph(): DimensionSpace\
private function handleTagSubtree(TagSubtree $command, CommandHandlingDependencies $commandHandlingDependencies): EventsToPublish
{
$contentGraph = $commandHandlingDependencies->getContentGraph($command->workspaceName);
$expectedVersion = ExpectedVersion::fromVersion($commandHandlingDependencies->getContentStreamVersion($contentGraph->getContentStreamId()));
$this->requireDimensionSpacePointToExist($command->coveredDimensionSpacePoint);
$nodeAggregate = $this->requireProjectedNodeAggregate($contentGraph, $command->nodeAggregateId);
$this->requireNodeAggregateToCoverDimensionSpacePoint(
Expand Down Expand Up @@ -76,13 +77,14 @@ private function handleTagSubtree(TagSubtree $command, CommandHandlingDependenci
$command,
$events
),
ExpectedVersion::ANY()
$expectedVersion
);
}

public function handleUntagSubtree(UntagSubtree $command, CommandHandlingDependencies $commandHandlingDependencies): EventsToPublish
{
$contentGraph = $commandHandlingDependencies->getContentGraph($command->workspaceName);
$expectedVersion = ExpectedVersion::fromVersion($commandHandlingDependencies->getContentStreamVersion($contentGraph->getContentStreamId()));
$this->requireDimensionSpacePointToExist($command->coveredDimensionSpacePoint);
$nodeAggregate = $this->requireProjectedNodeAggregate(
$contentGraph,
Expand Down Expand Up @@ -117,7 +119,7 @@ public function handleUntagSubtree(UntagSubtree $command, CommandHandlingDepende
return new EventsToPublish(
ContentStreamEventStreamName::fromContentStreamId($contentGraph->getContentStreamId())->getEventStreamName(),
RebaseableCommand::enrichWithCommand($command, $events),
ExpectedVersion::ANY()
$expectedVersion
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private function handleCreateWorkspace(
$command->newContentStreamId,
)
),
ExpectedVersion::ANY()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this slight change has a big impact as now after deleting a workspace a new one with the exact same name cannot be recreated.

And because \Neos\Neos\Domain\Service\WorkspaceService::getUniqueWorkspaceName only prevents naming conflict with existing workspaces that are projected attempting to create a workspace with the same title via Ui fails.

steps:

  1. create workspace 'MyTest'
  2. delete workspace
  3. repeat
image

The error is as expected:

Workspace could not be created.
Expected version: -1 [no stream], actual version: 1

That means imo that getUniqueWorkspaceName needs to handle this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good catch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this seems to hve no test then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jup the the core's DeleteWorkspace is fully untested - i have that somewhere in my todo list and stumble upon that every once and then. Also the cores CreateWorkspace is only tested implicit but not for such cases.

ExpectedVersion::NO_STREAM(),
);
}

Expand Down Expand Up @@ -182,7 +182,7 @@ private function handleCreateRootWorkspace(
$command->newContentStreamId
)
),
ExpectedVersion::ANY()
ExpectedVersion::NO_STREAM()
);
}

Expand Down