Skip to content

Commit

Permalink
Merge branch '9.0' into feature/4726-extract-workspace-metadata-and-u…
Browse files Browse the repository at this point in the history
…ser-assignment-to-neos
  • Loading branch information
bwaidelich committed Aug 2, 2024
2 parents 8975a5f + f1212cd commit 9c74b65
Show file tree
Hide file tree
Showing 364 changed files with 14,798 additions and 26,072 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use Behat\Gherkin\Node\TableNode;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames;
use Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory;
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentGraph.DoctrineDbalAdapter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"require": {
"neos/contentrepository-core": "self.version",
"doctrine/dbal": "^2.13",
"doctrine/dbal": "^3.1.4",
"doctrine/migrations": "*"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception as DbalException;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\Feature\NodeMove;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\Feature\NodeRemoval;
Expand Down Expand Up @@ -94,7 +94,7 @@ public function setUp(): void
foreach ($this->determineRequiredSqlStatements() as $statement) {
try {
$this->dbal->executeStatement($statement);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to setup projection %s: %s', self::class, $e->getMessage()), 1716478255, $e);
}
}
Expand Down Expand Up @@ -228,7 +228,7 @@ private function whenContentStreamWasForked(ContentStreamWasForked $event): void
$this->dbal->executeStatement($insertRelationStatement, [
'sourceContentStreamId' => $event->sourceContentStreamId->value
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to insert hierarchy relation: %s', $e->getMessage()), 1716489211, $e);
}

Expand All @@ -246,7 +246,7 @@ private function whenContentStreamWasRemoved(ContentStreamWasRemoved $event): vo
$this->dbal->executeStatement($deleteHierarchyRelationStatement, [
'contentStreamId' => $event->contentStreamId->value
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to delete hierarchy relations: %s', $e->getMessage()), 1716489265, $e);
}

Expand All @@ -260,7 +260,7 @@ private function whenContentStreamWasRemoved(ContentStreamWasRemoved $event): vo
SQL;
try {
$this->dbal->executeStatement($deleteNodesStatement);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to delete non-referenced nodes: %s', $e->getMessage()), 1716489294, $e);
}

Expand All @@ -274,7 +274,7 @@ private function whenContentStreamWasRemoved(ContentStreamWasRemoved $event): vo
SQL;
try {
$this->dbal->executeStatement($deleteReferenceRelationsStatement);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to delete non-referenced reference relations: %s', $e->getMessage()), 1716489328, $e);
}
}
Expand Down Expand Up @@ -311,7 +311,7 @@ private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded
'sourceDimensionSpacePointHash' => $event->source->hash,
'newDimensionSpacePointHash' => $event->target->hash,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to insert hierarchy relations: %s', $e->getMessage()), 1716490758, $e);
}
}
Expand Down Expand Up @@ -340,7 +340,7 @@ private function whenDimensionSpacePointWasMoved(DimensionSpacePointWasMoved $ev
'dimensionSpacePointHash' => $event->source->hash,
'contentStreamId' => $event->contentStreamId->value
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to load relation anchor points: %s', $e->getMessage()), 1716489628, $e);
}
foreach ($relationAnchorPoints as $relationAnchorPoint) {
Expand Down Expand Up @@ -369,7 +369,7 @@ function (NodeRecord $nodeRecord) use ($event) {
'newDimensionSpacePointHash' => $event->target->hash,
'contentStreamId' => $event->contentStreamId->value,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to update hierarchy relations: %s', $e->getMessage()), 1716489951, $e);
}
}
Expand Down Expand Up @@ -486,7 +486,7 @@ private function whenNodeReferencesWereSet(NodeReferencesWereSet $event, EventEn
foreach ($event->affectedSourceOriginDimensionSpacePoints as $originDimensionSpacePoint) {
$nodeAnchorPoint = $this->projectionContentGraph
->getAnchorPointForNodeAndOriginDimensionSpacePointAndContentStream(
$event->sourceNodeAggregateId,
$event->nodeAggregateId,
$originDimensionSpacePoint,
$event->contentStreamId
);
Expand Down Expand Up @@ -514,7 +514,7 @@ function (NodeRecord $node) use ($eventEnvelope) {

$nodeAnchorPoint = $this->projectionContentGraph
->getAnchorPointForNodeAndOriginDimensionSpacePointAndContentStream(
$event->sourceNodeAggregateId,
$event->nodeAggregateId,
$originDimensionSpacePoint,
$event->contentStreamId
);
Expand All @@ -525,7 +525,7 @@ function (NodeRecord $node) use ($eventEnvelope) {
'nodeanchorpoint' => $nodeAnchorPoint?->value,
'name' => $event->referenceName->value
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to remove reference relation: %s', $e->getMessage()), 1716486309, $e);
}

Expand All @@ -549,7 +549,7 @@ function (NodeRecord $node) use ($eventEnvelope) {
'destinationnodeaggregateid' => $reference->targetNodeAggregateId->value,
'properties' => $referencePropertiesJson,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to insert reference relation: %s', $e->getMessage()), 1716486309, $e);
}
$position++;
Expand Down Expand Up @@ -590,7 +590,7 @@ private function whenRootNodeAggregateDimensionsWereUpdated(RootNodeAggregateDim
'childNodeAnchor' => $rootNodeAnchorPoint->value,
'contentStreamId' => $event->contentStreamId->value,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to delete hierarchy relation: %s', $e->getMessage()), 1716488943, $e);
}
// recreate hierarchy edges for the root node
Expand Down Expand Up @@ -646,10 +646,7 @@ private function whenSubtreeWasUntagged(SubtreeWasUntagged $event): void
*/
private function determineRequiredSqlStatements(): array
{
$schemaManager = $this->dbal->getSchemaManager();
if (!$schemaManager instanceof AbstractSchemaManager) {
throw new \RuntimeException('Failed to retrieve Schema Manager', 1625653914);
}
$schemaManager = $this->dbal->createSchemaManager();
$schema = (new DoctrineDbalContentGraphSchemaBuilder($this->tableNames))->buildSchema($schemaManager);
return DbalSchemaDiff::determineRequiredSqlStatements($this->dbal, $schema);
}
Expand All @@ -661,7 +658,7 @@ private function truncateDatabaseTables(): void
$this->dbal->executeQuery('TRUNCATE table ' . $this->tableNames->hierarchyRelation());
$this->dbal->executeQuery('TRUNCATE table ' . $this->tableNames->referenceRelation());
$this->dbal->executeQuery('TRUNCATE table ' . $this->tableNames->dimensionSpacePoints());
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to truncate database tables for projection %s: %s', self::class, $e->getMessage()), 1716478318, $e);
}
}
Expand Down Expand Up @@ -709,7 +706,7 @@ private function updateNodeRecordWithCopyOnWrite(
'originalNodeAnchor' => $anchorPoint->value,
'contentStreamId' => $contentStreamIdWhereWriteOccurs->value,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to update hierarchy relation: %s', $e->getMessage()), 1716486444, $e);
}
// reference relation rows need to be copied as well!
Expand Down Expand Up @@ -756,7 +753,7 @@ private function copyReferenceRelations(
'sourceNodeAnchorPoint' => $sourceRelationAnchorPoint->value,
'destinationRelationAnchorPoint' => $destinationRelationAnchorPoint->value
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to copy reference relations: %s', $e->getMessage()), 1716489394, $e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Doctrine\DBAL\Exception as DbalException;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Schema;
Expand All @@ -23,6 +24,10 @@ public function __construct(
) {
}

/**
* @param AbstractSchemaManager<AbstractPlatform> $schemaManager
* @return Schema
*/
public function buildSchema(AbstractSchemaManager $schemaManager): Schema
{
return DbalSchemaFactory::createSchemaWithTables($schemaManager, [
Expand All @@ -40,8 +45,8 @@ private function createNodeTable(): Table
DbalSchemaFactory::columnForNodeAggregateId('nodeaggregateid')->setNotnull(false),
DbalSchemaFactory::columnForDimensionSpacePointHash('origindimensionspacepointhash')->setNotnull(false),
DbalSchemaFactory::columnForNodeTypeName('nodetypename'),
(new Column('name', self::type(Types::STRING)))->setLength(255)->setNotnull(false)->setCustomSchemaOption('charset', 'ascii')->setCustomSchemaOption('collation', 'ascii_general_ci'),
(new Column('properties', self::type(Types::TEXT)))->setNotnull(true)->setCustomSchemaOption('collation', self::DEFAULT_TEXT_COLLATION),
(new Column('name', self::type(Types::STRING)))->setLength(255)->setNotnull(false)->setPlatformOption('charset', 'ascii')->setPlatformOption('collation', 'ascii_general_ci'),
(new Column('properties', self::type(Types::TEXT)))->setNotnull(true)->setPlatformOption('collation', self::DEFAULT_TEXT_COLLATION),
(new Column('classification', self::type(Types::BINARY)))->setLength(20)->setNotnull(true),
(new Column('created', self::type(Types::DATETIME_IMMUTABLE)))->setDefault('CURRENT_TIMESTAMP')->setNotnull(true),
(new Column('originalcreated', self::type(Types::DATETIME_IMMUTABLE)))->setDefault('CURRENT_TIMESTAMP')->setNotnull(true),
Expand Down Expand Up @@ -88,10 +93,10 @@ private function createDimensionSpacePointsTable(): Table
private function createReferenceRelationTable(): Table
{
$table = self::createTable($this->contentGraphTableNames->referenceRelation(), [
(new Column('name', self::type(Types::STRING)))->setLength(255)->setNotnull(true)->setCustomSchemaOption('charset', 'ascii')->setCustomSchemaOption('collation', 'ascii_general_ci'),
(new Column('name', self::type(Types::STRING)))->setLength(255)->setNotnull(true)->setPlatformOption('charset', 'ascii')->setPlatformOption('collation', 'ascii_general_ci'),
(new Column('position', self::type(Types::INTEGER)))->setNotnull(true),
DbalSchemaFactory::columnForNodeAnchorPoint('nodeanchorpoint'),
(new Column('properties', self::type(Types::TEXT)))->setNotnull(false)->setCustomSchemaOption('collation', self::DEFAULT_TEXT_COLLATION),
(new Column('properties', self::type(Types::TEXT)))->setNotnull(false)->setPlatformOption('collation', self::DEFAULT_TEXT_COLLATION),
DbalSchemaFactory::columnForNodeAggregateId('destinationnodeaggregateid')->setNotnull(true)
]);

Expand All @@ -106,7 +111,7 @@ private static function createTable(string $tableName, array $columns): Table
{
try {
return new Table($tableName, $columns);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to create table "%s": %s', $tableName, $e->getMessage()), 1716490913, $e);
}
}
Expand All @@ -115,7 +120,7 @@ private static function type(string $type): Type
{
try {
return Type::getType($type);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to create database type "%s": %s', $type, $e->getMessage()), 1716491053, $e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

use Doctrine\DBAL\Exception as DbalException;
use Doctrine\DBAL\Exception as DBALException;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\HierarchyRelation;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
Expand Down Expand Up @@ -65,7 +65,7 @@ private function removeRelationRecursivelyFromDatabaseIncludingNonReferencedNode
$this->dbal->executeStatement($deleteRelationsStatement, [
'anchorPointForNode' => $ingoingRelation->childNodeAnchor->value,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to remove relations from database: %s', $e->getMessage()), 1716473385, $e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

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

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception as DbalException;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Exception as DBALException;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\NodeRelationAnchorPoint;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
Expand Down Expand Up @@ -58,9 +58,9 @@ private function addSubtreeTag(ContentStreamId $contentStreamId, NodeAggregateId
'dimensionSpacePointHashes' => $affectedDimensionSpacePoints->getPointHashes(),
'tagPath' => '$.' . $tag->value,
], [
'dimensionSpacePointHashes' => Connection::PARAM_STR_ARRAY,
'dimensionSpacePointHashes' => ArrayParameterType::STRING,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to add subtree tag %s for content stream %s, node aggregate id %s and dimension space points %s: %s', $tag->value, $contentStreamId->value, $nodeAggregateId->value, $affectedDimensionSpacePoints->toJson(), $e->getMessage()), 1716479749, $e);
}

Expand All @@ -80,9 +80,9 @@ private function addSubtreeTag(ContentStreamId $contentStreamId, NodeAggregateId
'dimensionSpacePointHashes' => $affectedDimensionSpacePoints->getPointHashes(),
'tagPath' => '$.' . $tag->value,
], [
'dimensionSpacePointHashes' => Connection::PARAM_STR_ARRAY,
'dimensionSpacePointHashes' => ArrayParameterType::STRING,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to add subtree tag %s for content stream %s, node aggregate id %s and dimension space points %s: %s', $tag->value, $contentStreamId->value, $nodeAggregateId->value, $affectedDimensionSpacePoints->toJson(), $e->getMessage()), 1716479840, $e);
}
}
Expand Down Expand Up @@ -135,9 +135,9 @@ private function removeSubtreeTag(ContentStreamId $contentStreamId, NodeAggregat
'dimensionSpacePointHashes' => $affectedDimensionSpacePoints->getPointHashes(),
'tagPath' => '$.' . $tag->value,
], [
'dimensionSpacePointHashes' => Connection::PARAM_STR_ARRAY,
'dimensionSpacePointHashes' => ArrayParameterType::STRING,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to remove subtree tag %s for content stream %s, node aggregate id %s and dimension space points %s: %s', $tag->value, $contentStreamId->value, $nodeAggregateId->value, $affectedDimensionSpacePoints->toJson(), $e->getMessage()), 1716482293, $e);
}
}
Expand Down Expand Up @@ -197,7 +197,7 @@ private function moveSubtreeTags(ContentStreamId $contentStreamId, NodeAggregate
'newParentNodeAggregateId' => $newParentNodeAggregateId->value,
'dimensionSpacePointHash' => $coveredDimensionSpacePoint->hash,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to move subtree tags for content stream %s, new parent node aggregate id %s and dimension space point %s: %s', $contentStreamId->value, $newParentNodeAggregateId->value, $coveredDimensionSpacePoint->toJson(), $e->getMessage()), 1716482574, $e);
}
}
Expand All @@ -219,7 +219,7 @@ private function subtreeTagsForHierarchyRelation(ContentStreamId $contentStreamI
'contentStreamId' => $contentStreamId->value,
'dimensionSpacePointHash' => $dimensionSpacePoint->hash,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to fetch subtree tags for hierarchy parent anchor point "%s" in content subgraph "%s@%s": %s', $parentNodeAnchorPoint->value, $dimensionSpacePoint->toJson(), $contentStreamId->value, $e->getMessage()), 1716478760, $e);
}
if (!is_string($subtreeTagsJson)) {
Expand Down
Loading

0 comments on commit 9c74b65

Please sign in to comment.