Skip to content

Commit

Permalink
Merge branch '9.0' into 5034-workspaceBasedTests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Schmitt committed May 11, 2024
2 parents a772403 + 6a47318 commit c5d4946
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ trait ProjectionIntegrityViolationDetectionTrait
*/
abstract private function getObject(string $className): object;

protected function getTableNamePrefix(): string
private function tableNames(): ContentGraphTableNames
{
return ContentGraphTableNames::create(
$this->currentContentRepository->id
)->tableNamePrefix;
);
}

public function setupDbalGraphAdapterIntegrityViolationTrait()
Expand All @@ -80,7 +80,7 @@ public function iRemoveTheFollowingSubtreeTag(TableNode $payloadTable): void
throw new \RuntimeException(sprintf('Failed to remove subtree tag "%s" because that tag is not set', $subtreeTagToRemove->value), 1708618267);
}
$this->dbalClient->getConnection()->update(
$this->getTableNamePrefix() . '_hierarchyrelation',
$this->tableNames()->hierarchyRelation(),
[
'subtreetags' => json_encode($subtreeTags->without($subtreeTagToRemove), JSON_THROW_ON_ERROR | JSON_FORCE_OBJECT),
],
Expand All @@ -97,7 +97,7 @@ public function iAddTheFollowingHierarchyRelation(TableNode $payloadTable): void
$dataset = $this->transformPayloadTableToDataset($payloadTable);
$record = $this->transformDatasetToHierarchyRelationRecord($dataset);
$this->dbalClient->getConnection()->insert(
$this->getTableNamePrefix() . '_hierarchyrelation',
$this->tableNames()->hierarchyRelation(),
$record
);
}
Expand All @@ -114,7 +114,7 @@ public function iChangeTheFollowingHierarchyRelationsDimensionSpacePointHash(Tab
unset($record['position']);

$this->dbalClient->getConnection()->update(
$this->getTableNamePrefix() . '_hierarchyrelation',
$this->tableNames()->hierarchyRelation(),
[
'dimensionspacepointhash' => $dataset['newDimensionSpacePointHash']
],
Expand All @@ -134,7 +134,7 @@ public function iChangeTheFollowingHierarchyRelationsEdgeName(TableNode $payload
unset($record['position']);

$this->dbalClient->getConnection()->update(
$this->getTableNamePrefix() . '_hierarchyrelation',
$this->tableNames()->hierarchyRelation(),
[
'name' => $dataset['newName']
],
Expand All @@ -158,7 +158,7 @@ public function iSetTheFollowingPosition(TableNode $payloadTable): void
];

$this->dbalClient->getConnection()->update(
$this->getTableNamePrefix() . '_hierarchyrelation',
$this->tableNames()->hierarchyRelation(),
[
'position' => $dataset['newPosition']
],
Expand All @@ -176,7 +176,7 @@ public function iDetachTheFollowingReferenceRelationFromItsSource(TableNode $pay
$dataset = $this->transformPayloadTableToDataset($payloadTable);

$this->dbalClient->getConnection()->update(
$this->getTableNamePrefix() . '_referencerelation',
$this->tableNames()->referenceRelation(),
[
'nodeanchorpoint' => 7777777
],
Expand All @@ -194,7 +194,7 @@ public function iSetTheFollowingReferencePosition(TableNode $payloadTable): void
$dataset = $this->transformPayloadTableToDataset($payloadTable);

$this->dbalClient->getConnection()->update(
$this->getTableNamePrefix() . '_referencerelation',
$this->tableNames()->referenceRelation(),
[
'position' => $dataset['newPosition']
],
Expand Down Expand Up @@ -265,8 +265,8 @@ private function findHierarchyRelationByIds(
): array {
$nodeRecord = $this->dbalClient->getConnection()->executeQuery(
'SELECT h.*
FROM ' . $this->getTableNamePrefix() . '_node n
INNER JOIN ' . $this->getTableNamePrefix() . '_hierarchyrelation h
FROM ' . $this->tableNames()->node() . ' n
INNER JOIN ' . $this->tableNames()->hierarchyRelation() . ' h
ON n.relationanchorpoint = h.childnodeanchor
WHERE n.nodeaggregateid = :nodeAggregateId
AND h.contentstreamid = :contentStreamId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final readonly class ContentGraphTableNames
{
private function __construct(
public string $tableNamePrefix
private string $tableNamePrefix
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Result;
use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames;
use Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjection;
use Neos\ContentGraph\DoctrineDbalAdapter\NodeQueryBuilder;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
Expand Down Expand Up @@ -316,15 +315,6 @@ public function findUsedNodeTypeNames(): iterable
);
}

/**
* @return ContentSubgraphWithRuntimeCaches[]
* @internal only used for {@see DoctrineDbalContentGraphProjection}
*/
public function getSubgraphs(): array
{
return $this->subgraphs;
}

private function createQueryBuilder(): QueryBuilder
{
return $this->client->getConnection()->createQueryBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ public function reset(): void

$this->checkpointStorage->acquireLock();
$this->checkpointStorage->updateAndReleaseLock(SequenceNumber::none());

//$contentGraph = $this->getState();
//foreach ($contentGraph->getSubgraphs() as $subgraph) {
// $subgraph->inMemoryCache->enable();
//}
}

private function truncateDatabaseTables(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ protected function requireNodeAggregateToOccupyDimensionSpacePoint(
): void {
if (!$nodeAggregate->occupiesDimensionSpacePoint($originDimensionSpacePoint)) {
throw new DimensionSpacePointIsNotYetOccupied(
'Dimension space point ' . json_encode($originDimensionSpacePoint, JSON_THROW_ON_ERROR)
'Dimension space point ' . json_encode($originDimensionSpacePoint, JSON_PARTIAL_OUTPUT_ON_ERROR)
. ' is not yet occupied by node aggregate "' . $nodeAggregate->nodeAggregateId->value . '"',
1552595396
);
Expand All @@ -687,7 +687,7 @@ protected function requireNodeAggregateToNotOccupyDimensionSpacePoint(
): void {
if ($nodeAggregate->occupiesDimensionSpacePoint($originDimensionSpacePoint)) {
throw new DimensionSpacePointIsAlreadyOccupied(
'Dimension space point ' . json_encode($originDimensionSpacePoint, JSON_THROW_ON_ERROR)
'Dimension space point ' . json_encode($originDimensionSpacePoint, JSON_PARTIAL_OUTPUT_ON_ERROR)
. ' is already occupied by node aggregate "' . $nodeAggregate->nodeAggregateId->value . '"',
1552595441
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function canHandle(CommandInterface $command): bool
public function handle(CommandInterface $command, CommandHandlingDependencies $commandHandlingDependencies): EventsToPublish
{
return match ($command::class) {
CreateContentStream::class => $this->handleCreateContentStream($command),
CreateContentStream::class => $this->handleCreateContentStream($command, $commandHandlingDependencies),
CloseContentStream::class => $this->handleCloseContentStream($command, $commandHandlingDependencies),
ReopenContentStream::class => $this->handleReopenContentStream($command, $commandHandlingDependencies),
ForkContentStream::class => $this->handleForkContentStream($command, $commandHandlingDependencies),
Expand All @@ -66,8 +66,10 @@ public function handle(CommandInterface $command, CommandHandlingDependencies $c
* @throws ContentStreamAlreadyExists
*/
private function handleCreateContentStream(
CreateContentStream $command
CreateContentStream $command,
CommandHandlingDependencies $commandHandlingDependencies,
): EventsToPublish {
$this->requireContentStreamToNotExistYet($command->contentStreamId, $commandHandlingDependencies);
$streamName = ContentStreamEventStreamName::fromContentStreamId($command->contentStreamId)
->getEventStreamName();

Expand Down Expand Up @@ -133,8 +135,8 @@ private function handleForkContentStream(
): EventsToPublish {
$this->requireContentStreamToExist($command->sourceContentStreamId, $commandHandlingDependencies);
$this->requireContentStreamToNotBeClosed($command->sourceContentStreamId, $commandHandlingDependencies);
$this->requireContentStreamToNotExistYet($command->newContentStreamId, $commandHandlingDependencies);

// TODO: This is not great
$sourceContentStreamVersion = $commandHandlingDependencies->getContentStreamFinder()->findVersionForContentStream($command->sourceContentStreamId);

$streamName = ContentStreamEventStreamName::fromContentStreamId($command->newContentStreamId)
Expand Down Expand Up @@ -178,6 +180,24 @@ private function handleRemoveContentStream(

/**
* @param ContentStreamId $contentStreamId
* @param CommandHandlingDependencies $commandHandlingDependencies
* @throws ContentStreamAlreadyExists
*/
protected function requireContentStreamToNotExistYet(
ContentStreamId $contentStreamId,
CommandHandlingDependencies $commandHandlingDependencies
): void {
if ($commandHandlingDependencies->getContentStreamFinder()->hasContentStream($contentStreamId)) {
throw new ContentStreamAlreadyExists(
'Content stream "' . $contentStreamId->value . '" already exists.',
1521386345
);
}
}

/**
* @param ContentStreamId $contentStreamId
* @param CommandHandlingDependencies $commandHandlingDependencies
* @throws ContentStreamDoesNotExistYet
*/
protected function requireContentStreamToExist(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,21 @@ public function findVersionForContentStream(ContentStreamId $contentStreamId): M

return MaybeVersion::fromVersionOrNull(Version::fromInteger($version));
}

public function hasContentStream(ContentStreamId $contentStreamId): bool
{
$connection = $this->client->getConnection();
/* @var $state string|false */
$version = $connection->executeQuery(
'
SELECT version FROM ' . $this->tableName . '
WHERE contentStreamId = :contentStreamId
',
[
'contentStreamId' => $contentStreamId->value
]
)->fetchOne();

return $version !== false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function beforeEventSourcedScenarioDispatcher(BeforeScenarioScope $scope)
$this->currentDimensionSpacePoint = null;
$this->currentRootNodeAggregateId = null;
$this->currentContentStreamId = null;
$this->currentWorkspaceName = null;
$this->currentNodeAggregate = null;
$this->currentNode = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/**
* @internal
*/

#[Flow\Proxy(false)]
readonly class AssetIdAndOriginalAssetId
{
Expand Down
2 changes: 0 additions & 2 deletions Neos.Neos/Classes/Fusion/Cache/ContentCacheFlusher.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public function __construct(
/**
* Main entry point to *directly* flush the caches of a given NodeAggregate
*
* FIXME workspaceName instead of contentStreamId
*
* @param ContentRepository $contentRepository
* @param ContentStreamId $contentStreamId
* @param NodeAggregateId $nodeAggregateId
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Documentation/References/CommandReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ commands that may be available, use::

./flow help

The following reference was automatically generated from code on 2024-05-06
The following reference was automatically generated from code on 2024-05-11


.. _`Neos Command Reference: NEOS.FLOW`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FluidAdaptor ViewHelper Reference
#################################

This reference was automatically generated from code on 2024-05-06
This reference was automatically generated from code on 2024-05-11


.. _`FluidAdaptor ViewHelper Reference: f:debug`:
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Documentation/References/ViewHelpers/Form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Form ViewHelper Reference
#########################

This reference was automatically generated from code on 2024-05-06
This reference was automatically generated from code on 2024-05-11


.. _`Form ViewHelper Reference: neos.form:form`:
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Documentation/References/ViewHelpers/Media.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Media ViewHelper Reference
##########################

This reference was automatically generated from code on 2024-05-06
This reference was automatically generated from code on 2024-05-11


.. _`Media ViewHelper Reference: neos.media:fileTypeIcon`:
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Documentation/References/ViewHelpers/Neos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Neos ViewHelper Reference
#########################

This reference was automatically generated from code on 2024-05-06
This reference was automatically generated from code on 2024-05-11


.. _`Neos ViewHelper Reference: neos:backend.authenticationProviderLabel`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
TYPO3 Fluid ViewHelper Reference
################################

This reference was automatically generated from code on 2024-05-06
This reference was automatically generated from code on 2024-05-11


.. _`TYPO3 Fluid ViewHelper Reference: f:alias`:
Expand Down

0 comments on commit c5d4946

Please sign in to comment.