Skip to content

Commit

Permalink
Merge pull request #5161 from kitsunet/task/90-doctrine-dbal-update
Browse files Browse the repository at this point in the history
!!! TASK: Raise doctrine/dbal version constraint
  • Loading branch information
kitsunet authored Jul 11, 2024
2 parents 78bdd81 + a7238d8 commit 73fa331
Show file tree
Hide file tree
Showing 165 changed files with 873 additions and 809 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\Exception;
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 @@ -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,7 @@

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;
Expand Down Expand Up @@ -45,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 @@ -93,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 @@ -111,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 @@ -120,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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception as DbalException;
use Doctrine\DBAL\Exception as DBALException;
use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\DimensionSpacePointsRepository;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function addToDatabase(Connection $databaseConnection, ContentGraphTableN
'position' => $this->position,
'subtreetags' => $subtreeTagsJson,
]);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to add hierarchy relation to database: %s', $e->getMessage()), 1716484789, $e);
}
}
Expand All @@ -68,7 +68,7 @@ public function removeFromDatabase(Connection $databaseConnection, ContentGraphT
{
try {
$databaseConnection->delete($tableNames->hierarchyRelation(), $this->getDatabaseId());
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to remove hierarchy relation from database: %s', $e->getMessage()), 1716484823, $e);
}
}
Expand All @@ -86,7 +86,7 @@ public function assignNewChildNode(
],
$this->getDatabaseId()
);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to update hierarchy relation: %s', $e->getMessage()), 1716484843, $e);
}
}
Expand All @@ -109,7 +109,7 @@ public function assignNewParentNode(
$data,
$this->getDatabaseId()
);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to update hierarchy relation: %s', $e->getMessage()), 1716478609, $e);
}
}
Expand All @@ -124,7 +124,7 @@ public function assignNewPosition(int $position, Connection $databaseConnection,
],
$this->getDatabaseId()
);
} catch (DbalException $e) {
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to update hierarchy relation: %s', $e->getMessage()), 1716485014, $e);
}
}
Expand Down
Loading

0 comments on commit 73fa331

Please sign in to comment.