diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php index 873a700ea17..4e21b0ae39e 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php @@ -15,6 +15,7 @@ namespace Neos\ContentGraph\DoctrineDbalAdapter\Tests\Behavior\Features\Bootstrap; use Behat\Gherkin\Node\TableNode; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Exception\InvalidArgumentException; use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames; @@ -27,7 +28,6 @@ use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteRuntimeVariables; -use Neos\ContentRepositoryRegistry\DoctrineDbalClient\DoctrineDbalClient; use Neos\Error\Messages\Error; use Neos\Error\Messages\Result; use PHPUnit\Framework\Assert; @@ -41,7 +41,7 @@ trait ProjectionIntegrityViolationDetectionTrait { use CRTestSuiteRuntimeVariables; - private DoctrineDbalClient $dbalClient; + private Connection $dbal; protected Result $lastIntegrityViolationDetectionResult; @@ -62,7 +62,7 @@ private function tableNames(): ContentGraphTableNames public function setupDbalGraphAdapterIntegrityViolationTrait() { - $this->dbalClient = $this->getObject(DoctrineDbalClient::class); + $this->dbal = $this->getObject(Connection::class); } /** @@ -80,7 +80,7 @@ public function iRemoveTheFollowingSubtreeTag(TableNode $payloadTable): void if (!$subtreeTags->contain($subtreeTagToRemove)) { throw new \RuntimeException(sprintf('Failed to remove subtree tag "%s" because that tag is not set', $subtreeTagToRemove->value), 1708618267); } - $this->dbalClient->getConnection()->update( + $this->dbal->update( $this->tableNames()->hierarchyRelation(), [ 'subtreetags' => json_encode($subtreeTags->without($subtreeTagToRemove), JSON_THROW_ON_ERROR | JSON_FORCE_OBJECT), @@ -97,7 +97,7 @@ public function iAddTheFollowingHierarchyRelation(TableNode $payloadTable): void { $dataset = $this->transformPayloadTableToDataset($payloadTable); $record = $this->transformDatasetToHierarchyRelationRecord($dataset); - $this->dbalClient->getConnection()->insert( + $this->dbal->insert( $this->tableNames()->hierarchyRelation(), $record ); @@ -114,7 +114,7 @@ public function iChangeTheFollowingHierarchyRelationsDimensionSpacePointHash(Tab $record = $this->transformDatasetToHierarchyRelationRecord($dataset); unset($record['position']); - $this->dbalClient->getConnection()->update( + $this->dbal->update( $this->tableNames()->hierarchyRelation(), [ 'dimensionspacepointhash' => $dataset['newDimensionSpacePointHash'] @@ -132,7 +132,7 @@ public function iChangeTheFollowingNodesName(TableNode $payloadTable): void { $dataset = $this->transformPayloadTableToDataset($payloadTable); - $relationAnchorPoint = $this->dbalClient->getConnection()->executeQuery( + $relationAnchorPoint = $this->dbal->executeQuery( 'SELECT n.relationanchorpoint FROM ' . $this->tableNames()->node() . ' n JOIN ' . $this->tableNames()->hierarchyRelation() . ' h ON h.childnodeanchor = n.relationanchorpoint WHERE h.contentstreamid = :contentStreamId @@ -145,7 +145,7 @@ public function iChangeTheFollowingNodesName(TableNode $payloadTable): void ] )->fetchOne(); - $this->dbalClient->getConnection()->update( + $this->dbal->update( $this->tableNames()->node(), [ 'name' => $dataset['newName'] @@ -171,7 +171,7 @@ public function iSetTheFollowingPosition(TableNode $payloadTable): void 'childnodeanchor' => $this->findRelationAnchorPointByDataset($dataset) ]; - $this->dbalClient->getConnection()->update( + $this->dbal->update( $this->tableNames()->hierarchyRelation(), [ 'position' => $dataset['newPosition'] @@ -189,7 +189,7 @@ public function iDetachTheFollowingReferenceRelationFromItsSource(TableNode $pay { $dataset = $this->transformPayloadTableToDataset($payloadTable); - $this->dbalClient->getConnection()->update( + $this->dbal->update( $this->tableNames()->referenceRelation(), [ 'nodeanchorpoint' => 7777777 @@ -207,7 +207,7 @@ public function iSetTheFollowingReferencePosition(TableNode $payloadTable): void { $dataset = $this->transformPayloadTableToDataset($payloadTable); - $this->dbalClient->getConnection()->update( + $this->dbal->update( $this->tableNames()->referenceRelation(), [ 'position' => $dataset['newPosition'] @@ -277,7 +277,7 @@ private function findHierarchyRelationByIds( DimensionSpacePoint $dimensionSpacePoint, NodeAggregateId $nodeAggregateId ): array { - $nodeRecord = $this->dbalClient->getConnection()->executeQuery( + $nodeRecord = $this->dbal->executeQuery( 'SELECT h.* FROM ' . $this->tableNames()->node() . ' n INNER JOIN ' . $this->tableNames()->hierarchyRelation() . ' h @@ -313,7 +313,7 @@ private function transformPayloadTableToDataset(TableNode $payloadTable): array */ public function iRunIntegrityViolationDetection(): void { - $projectionIntegrityViolationDetectionRunner = $this->getContentRepositoryService(new DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory($this->dbalClient)); + $projectionIntegrityViolationDetectionRunner = $this->getContentRepositoryService(new DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory($this->dbal)); $this->lastIntegrityViolationDetectionResult = $projectionIntegrityViolationDetectionRunner->run(); } diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php index 66ae7720899..6af078fac08 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php @@ -12,10 +12,10 @@ namespace Neos\ContentGraph\DoctrineDbalAdapter; +use Doctrine\DBAL\Connection; use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ContentGraph; use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory; use Neos\ContentRepository\Core\ContentGraphFactoryInterface; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist; @@ -29,7 +29,7 @@ final readonly class ContentGraphFactory implements ContentGraphFactoryInterface { public function __construct( - private DbalClientInterface $client, + private Connection $dbal, private NodeFactory $nodeFactory, private ContentRepositoryId $contentRepositoryId, private NodeTypeManager $nodeTypeManager, @@ -46,7 +46,7 @@ public function buildForWorkspace(WorkspaceName $workspaceName): ContentGraph 'workspace' )); - $row = $this->client->getConnection()->executeQuery( + $row = $this->dbal->executeQuery( ' SELECT * FROM ' . $tableName . ' WHERE workspaceName = :workspaceName @@ -66,6 +66,6 @@ public function buildForWorkspace(WorkspaceName $workspaceName): ContentGraph public function buildForWorkspaceAndContentStream(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraph { - return new ContentGraph($this->client, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNames, $workspaceName, $contentStreamId); + return new ContentGraph($this->dbal, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNames, $workspaceName, $contentStreamId); } } diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php index ade91c5d169..9623ae4bc1d 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php @@ -44,7 +44,6 @@ use Neos\ContentRepository\Core\Feature\SubtreeTagging\Event\SubtreeWasTagged; use Neos\ContentRepository\Core\Feature\SubtreeTagging\Event\SubtreeWasUntagged; use Neos\ContentRepository\Core\Infrastructure\DbalCheckpointStorage; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Infrastructure\DbalSchemaDiff; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\CheckpointStorageStatusType; @@ -76,14 +75,14 @@ final class DoctrineDbalContentGraphProjection implements ProjectionInterface private DbalCheckpointStorage $checkpointStorage; public function __construct( - private readonly DbalClientInterface $dbalClient, + private readonly Connection $dbal, private readonly ProjectionContentGraph $projectionContentGraph, private readonly ContentGraphTableNames $tableNames, private readonly DimensionSpacePointsRepository $dimensionSpacePointsRepository, private readonly ContentGraphFinder $contentGraphFinder ) { $this->checkpointStorage = new DbalCheckpointStorage( - $this->dbalClient->getConnection(), + $this->dbal, $this->tableNames->checkpoint(), self::class ); @@ -107,13 +106,12 @@ public function setUp(): void */ private function determineRequiredSqlStatements(): array { - $connection = $this->dbalClient->getConnection(); - $schemaManager = $connection->getSchemaManager(); + $schemaManager = $this->dbal->getSchemaManager(); if (!$schemaManager instanceof AbstractSchemaManager) { throw new \RuntimeException('Failed to retrieve Schema Manager', 1625653914); } $schema = (new DoctrineDbalContentGraphSchemaBuilder($this->tableNames))->buildSchema($schemaManager); - return DbalSchemaDiff::determineRequiredSqlStatements($connection, $schema); + return DbalSchemaDiff::determineRequiredSqlStatements($this->dbal, $schema); } public function status(): ProjectionStatus @@ -152,11 +150,10 @@ public function reset(): void private function truncateDatabaseTables(): void { - $connection = $this->dbalClient->getConnection(); - $connection->executeQuery('TRUNCATE table ' . $this->tableNames->node()); - $connection->executeQuery('TRUNCATE table ' . $this->tableNames->hierarchyRelation()); - $connection->executeQuery('TRUNCATE table ' . $this->tableNames->referenceRelation()); - $connection->executeQuery('TRUNCATE table ' . $this->tableNames->dimensionSpacePoints()); + $this->dbal->executeQuery('TRUNCATE table ' . $this->tableNames->node()); + $this->dbal->executeQuery('TRUNCATE table ' . $this->tableNames->hierarchyRelation()); + $this->dbal->executeQuery('TRUNCATE table ' . $this->tableNames->referenceRelation()); + $this->dbal->executeQuery('TRUNCATE table ' . $this->tableNames->dimensionSpacePoints()); } public function canHandle(EventInterface $event): bool @@ -988,7 +985,7 @@ private function transactional(\Closure $operations): void private function getDatabaseConnection(): Connection { - return $this->dbalClient->getConnection(); + return $this->dbal; } private static function initiatingDateTime(EventEnvelope $eventEnvelope): \DateTimeImmutable diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjectionFactory.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjectionFactory.php index 402d767abcf..6dc2dce7f5e 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjectionFactory.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjectionFactory.php @@ -4,15 +4,14 @@ namespace Neos\ContentGraph\DoctrineDbalAdapter; +use Doctrine\DBAL\Connection; use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\DimensionSpacePointsRepository; use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory; use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ProjectionContentGraph; use Neos\ContentRepository\Core\ContentGraphFinder; use Neos\ContentRepository\Core\Factory\ProjectionFactoryDependencies; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphProjection; use Neos\ContentRepository\Core\Projection\ProjectionFactoryInterface; -use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; /** * Use this class as ProjectionFactory in your configuration to construct a content graph @@ -24,7 +23,7 @@ final class DoctrineDbalContentGraphProjectionFactory implements ProjectionFactoryInterface { public function __construct( - private readonly DbalClientInterface $dbalClient + private readonly Connection $dbal, ) { } @@ -36,7 +35,7 @@ public function build( $projectionFactoryDependencies->contentRepositoryId ); - $dimensionSpacePointsRepository = new DimensionSpacePointsRepository($this->dbalClient->getConnection(), $tableNames); + $dimensionSpacePointsRepository = new DimensionSpacePointsRepository($this->dbal, $tableNames); $nodeFactory = new NodeFactory( $projectionFactoryDependencies->contentRepositoryId, @@ -46,7 +45,7 @@ public function build( ); $contentGraphFactory = new ContentGraphFactory( - $this->dbalClient, + $this->dbal, $nodeFactory, $projectionFactoryDependencies->contentRepositoryId, $projectionFactoryDependencies->nodeTypeManager, @@ -55,9 +54,9 @@ public function build( return new ContentGraphProjection( new DoctrineDbalContentGraphProjection( - $this->dbalClient, + $this->dbal, new ProjectionContentGraph( - $this->dbalClient, + $this->dbal, $tableNames ), $tableNames, diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory.php index 2daf3c6a5b9..377d74683fa 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory.php @@ -2,10 +2,10 @@ namespace Neos\ContentGraph\DoctrineDbalAdapter; +use Doctrine\DBAL\Connection; use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\ProjectionIntegrityViolationDetector; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryDependencies; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\ProjectionIntegrityViolationDetectionRunner; /** @@ -15,7 +15,7 @@ class DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory implements ContentRepositoryServiceFactoryInterface { public function __construct( - private readonly DbalClientInterface $dbalClient + private readonly Connection $dbal, ) { } @@ -24,7 +24,7 @@ public function build( ): ProjectionIntegrityViolationDetectionRunner { return new ProjectionIntegrityViolationDetectionRunner( new ProjectionIntegrityViolationDetector( - $this->dbalClient, + $this->dbal, ContentGraphTableNames::create( $serviceFactoryDependencies->contentRepositoryId ) diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Projection/ProjectionIntegrityViolationDetector.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Projection/ProjectionIntegrityViolationDetector.php index 78722fbff69..d49ee7fdaca 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Projection/ProjectionIntegrityViolationDetector.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Projection/ProjectionIntegrityViolationDetector.php @@ -14,10 +14,10 @@ namespace Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection; +use Doctrine\DBAL\Connection; use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\ProjectionIntegrityViolationDetectorInterface; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; @@ -33,8 +33,8 @@ final class ProjectionIntegrityViolationDetector implements ProjectionIntegrityViolationDetectorInterface { public function __construct( - private readonly DbalClientInterface $client, - private readonly ContentGraphTableNames $tableNames + private readonly Connection $dbal, + private readonly ContentGraphTableNames $tableNames, ) { } @@ -45,7 +45,7 @@ public function hierarchyIntegrityIsProvided(): Result { $result = new Result(); - $disconnectedHierarchyRelationRecords = $this->client->getConnection()->executeQuery( + $disconnectedHierarchyRelationRecords = $this->dbal->executeQuery( 'SELECT h.* FROM ' . $this->tableNames->hierarchyRelation() . ' h LEFT JOIN ' . $this->tableNames->node() . ' p ON h.parentnodeanchor = p.relationanchorpoint LEFT JOIN ' . $this->tableNames->node() . ' c ON h.childnodeanchor = c.relationanchorpoint @@ -67,7 +67,7 @@ public function hierarchyIntegrityIsProvided(): Result )); } - $invalidlyHashedHierarchyRelationRecords = $this->client->getConnection()->executeQuery( + $invalidlyHashedHierarchyRelationRecords = $this->dbal->executeQuery( 'SELECT * FROM ' . $this->tableNames->hierarchyRelation() . ' h LEFT JOIN ' . $this->tableNames->dimensionSpacePoints() . ' dsp ON dsp.hash = h.dimensionspacepointhash HAVING dsp.dimensionspacepoint IS NULL' )->fetchAllAssociative(); @@ -80,7 +80,7 @@ public function hierarchyIntegrityIsProvided(): Result )); } - $hierarchyRelationRecordsAppearingMultipleTimes = $this->client->getConnection()->executeQuery( + $hierarchyRelationRecordsAppearingMultipleTimes = $this->dbal->executeQuery( 'SELECT COUNT(*) as uniquenessCounter, h.* FROM ' . $this->tableNames->hierarchyRelation() . ' h LEFT JOIN ' . $this->tableNames->node() . ' p ON h.parentnodeanchor = p.relationanchorpoint LEFT JOIN ' . $this->tableNames->node() . ' c ON h.childnodeanchor = c.relationanchorpoint @@ -112,7 +112,7 @@ public function siblingsAreDistinctlySorted(): Result { $result = new Result(); - $ambiguouslySortedHierarchyRelationRecords = $this->client->getConnection()->executeQuery( + $ambiguouslySortedHierarchyRelationRecords = $this->dbal->executeQuery( 'SELECT *, COUNT(position) FROM ' . $this->tableNames->hierarchyRelation() . ' GROUP BY position, parentnodeanchor, contentstreamid, dimensionspacepointhash @@ -126,7 +126,7 @@ public function siblingsAreDistinctlySorted(): Result $dimensionSpacePoints = $this->findProjectedDimensionSpacePoints(); foreach ($ambiguouslySortedHierarchyRelationRecords as $hierarchyRelationRecord) { - $ambiguouslySortedNodeRecords = $this->client->getConnection()->executeQuery( + $ambiguouslySortedNodeRecords = $this->dbal->executeQuery( 'SELECT nodeaggregateid FROM ' . $this->tableNames->node() . ' WHERE relationanchorpoint = :relationAnchorPoint', @@ -154,7 +154,7 @@ public function siblingsAreDistinctlySorted(): Result public function tetheredNodesAreNamed(): Result { $result = new Result(); - $unnamedTetheredNodeRecords = $this->client->getConnection()->executeQuery( + $unnamedTetheredNodeRecords = $this->dbal->executeQuery( 'SELECT n.nodeaggregateid, h.contentstreamid FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h @@ -189,7 +189,7 @@ public function subtreeTagsAreInherited(): Result // NOTE: // This part determines if a parent hierarchy relation contains subtree tags that are not existing in the child relation. // This could probably be solved with JSON_ARRAY_INTERSECT(JSON_KEYS(ph.subtreetags), JSON_KEYS(h.subtreetags) but unfortunately that's only available with MariaDB 11.2+ according to https://mariadb.com/kb/en/json_array_intersect/ - $hierarchyRelationsWithMissingSubtreeTags = $this->client->getConnection()->executeQuery( + $hierarchyRelationsWithMissingSubtreeTags = $this->dbal->executeQuery( 'SELECT ph.* FROM @@ -222,7 +222,7 @@ public function referenceIntegrityIsProvided(): Result { $result = new Result(); - $referenceRelationRecordsDetachedFromSource = $this->client->getConnection()->executeQuery( + $referenceRelationRecordsDetachedFromSource = $this->dbal->executeQuery( 'SELECT * FROM ' . $this->tableNames->referenceRelation() . ' WHERE nodeanchorpoint NOT IN ( SELECT relationanchorpoint FROM ' . $this->tableNames->node() . ' @@ -237,7 +237,7 @@ public function referenceIntegrityIsProvided(): Result )); } - $referenceRelationRecordsWithInvalidTarget = $this->client->getConnection()->executeQuery( + $referenceRelationRecordsWithInvalidTarget = $this->dbal->executeQuery( 'SELECT sh.contentstreamid AS contentstreamId, s.nodeaggregateid AS sourceNodeAggregateId, r.destinationnodeaggregateid AS destinationNodeAggregateId @@ -287,7 +287,7 @@ public function allNodesAreConnectedToARootNodePerSubgraph(): Result foreach ($this->findProjectedContentStreamIds() as $contentStreamId) { foreach ($this->findProjectedDimensionSpacePoints() as $dimensionSpacePoint) { - $nodeAggregateIdsInCycles = $this->client->getConnection()->executeQuery( + $nodeAggregateIdsInCycles = $this->dbal->executeQuery( 'WITH RECURSIVE subgraph AS ( SELECT h.childnodeanchor @@ -363,7 +363,7 @@ public function nodeAggregateIdsAreUniquePerSubgraph(): Result $result = new Result(); foreach ($this->findProjectedContentStreamIds() as $contentStreamId) { foreach ($this->findProjectedDimensionSpacePoints() as $dimensionSpacePoint) { - $ambiguousNodeAggregateRecords = $this->client->getConnection()->executeQuery( + $ambiguousNodeAggregateRecords = $this->dbal->executeQuery( 'SELECT n.nodeaggregateid, COUNT(n.relationanchorpoint) FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h @@ -400,7 +400,7 @@ public function allNodesHaveAtMostOneParentPerSubgraph(): Result $result = new Result(); foreach ($this->findProjectedContentStreamIds() as $contentStreamId) { foreach ($this->findProjectedDimensionSpacePoints() as $dimensionSpacePoint) { - $nodeRecordsWithMultipleParents = $this->client->getConnection()->executeQuery( + $nodeRecordsWithMultipleParents = $this->dbal->executeQuery( 'SELECT c.nodeaggregateid FROM ' . $this->tableNames->node() . ' c INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h @@ -441,7 +441,7 @@ public function nodeAggregatesAreConsistentlyTypedPerContentStream(): Result $contentStreamId ) as $nodeAggregateId ) { - $nodeAggregateRecords = $this->client->getConnection()->executeQuery( + $nodeAggregateRecords = $this->dbal->executeQuery( 'SELECT DISTINCT n.nodetypename FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h ON h.childnodeanchor = n.relationanchorpoint @@ -484,7 +484,7 @@ public function nodeAggregatesAreConsistentlyClassifiedPerContentStream(): Resul $contentStreamId ) as $nodeAggregateId ) { - $nodeAggregateRecords = $this->client->getConnection()->executeQuery( + $nodeAggregateRecords = $this->dbal->executeQuery( 'SELECT DISTINCT n.classification FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h ON h.childnodeanchor = n.relationanchorpoint @@ -522,7 +522,7 @@ public function childNodeCoverageIsASubsetOfParentNodeCoverage(): Result { $result = new Result(); foreach ($this->findProjectedContentStreamIds() as $contentStreamId) { - $excessivelyCoveringNodeRecords = $this->client->getConnection()->executeQuery( + $excessivelyCoveringNodeRecords = $this->dbal->executeQuery( 'SELECT n.nodeaggregateid, c.dimensionspacepointhash FROM ' . $this->tableNames->hierarchyRelation() . ' c INNER JOIN ' . $this->tableNames->node() . ' n @@ -559,7 +559,7 @@ public function allNodesCoverTheirOrigin(): Result { $result = new Result(); foreach ($this->findProjectedContentStreamIds() as $contentStreamId) { - $nodeRecordsWithMissingOriginCoverage = $this->client->getConnection()->executeQuery( + $nodeRecordsWithMissingOriginCoverage = $this->dbal->executeQuery( 'SELECT nodeaggregateid, origindimensionspacepointhash FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h @@ -603,9 +603,7 @@ public function allNodesCoverTheirOrigin(): Result */ protected function findProjectedContentStreamIds(): iterable { - $connection = $this->client->getConnection(); - - $rows = $connection->executeQuery( + $rows = $this->dbal->executeQuery( 'SELECT DISTINCT contentstreamid FROM ' . $this->tableNames->hierarchyRelation() )->fetchAllAssociative(); @@ -621,7 +619,7 @@ protected function findProjectedContentStreamIds(): iterable */ protected function findProjectedDimensionSpacePoints(): DimensionSpacePointSet { - $records = $this->client->getConnection()->executeQuery( + $records = $this->dbal->executeQuery( 'SELECT dimensionspacepoint FROM ' . $this->tableNames->dimensionSpacePoints() )->fetchAllAssociative(); @@ -639,7 +637,7 @@ protected function findProjectedDimensionSpacePoints(): DimensionSpacePointSet protected function findProjectedNodeAggregateIdsInContentStream( ContentStreamId $contentStreamId ): array { - $records = $this->client->getConnection()->executeQuery( + $records = $this->dbal->executeQuery( 'SELECT DISTINCT nodeaggregateid FROM ' . $this->tableNames->node() )->fetchAllAssociative(); diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php index 54f5799f5ea..b5992bd4a02 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php @@ -24,7 +24,6 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface; @@ -73,7 +72,7 @@ final class ContentGraph implements ContentGraphInterface private array $subgraphs = []; public function __construct( - private readonly DbalClientInterface $client, + private readonly Connection $dbal, private readonly NodeFactory $nodeFactory, private readonly ContentRepositoryId $contentRepositoryId, private readonly NodeTypeManager $nodeTypeManager, @@ -81,7 +80,7 @@ public function __construct( public readonly WorkspaceName $workspaceName, public readonly ContentStreamId $contentStreamId ) { - $this->nodeQueryBuilder = new NodeQueryBuilder($this->client->getConnection(), $this->tableNames); + $this->nodeQueryBuilder = new NodeQueryBuilder($this->dbal, $this->tableNames); } public function getContentRepositoryId(): ContentRepositoryId @@ -107,7 +106,7 @@ public function getSubgraph( $this->contentStreamId, $dimensionSpacePoint, $visibilityConstraints, - $this->client, + $this->dbal, $this->nodeFactory, $this->nodeTypeManager, $this->tableNames @@ -330,7 +329,7 @@ public function findUsedNodeTypeNames(): iterable private function createQueryBuilder(): QueryBuilder { - return $this->client->getConnection()->createQueryBuilder(); + return $this->dbal->createQueryBuilder(); } private function mapQueryBuilderToNodeAggregate(QueryBuilder $queryBuilder): ?NodeAggregate diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentSubgraph.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentSubgraph.php index 504ca01ca1a..57774559fa8 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentSubgraph.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentSubgraph.php @@ -14,6 +14,7 @@ namespace Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\Exception as DbalDriverException; use Doctrine\DBAL\Exception as DbalException; use Doctrine\DBAL\ForwardCompatibility\Result; @@ -21,7 +22,6 @@ use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames; use Neos\ContentGraph\DoctrineDbalAdapter\NodeQueryBuilder; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath; @@ -96,12 +96,12 @@ public function __construct( private readonly ContentStreamId $contentStreamId, private readonly DimensionSpacePoint $dimensionSpacePoint, private readonly VisibilityConstraints $visibilityConstraints, - private readonly DbalClientInterface $client, + private readonly Connection $dbal, private readonly NodeFactory $nodeFactory, private readonly NodeTypeManager $nodeTypeManager, ContentGraphTableNames $tableNames ) { - $this->nodeQueryBuilder = new NodeQueryBuilder($this->client->getConnection(), $tableNames); + $this->nodeQueryBuilder = new NodeQueryBuilder($this->dbal, $tableNames); } public function getContentRepositoryId(): ContentRepositoryId @@ -467,7 +467,7 @@ private function findNodeByPathFromStartingNode(NodePath $path, Node $startingNo private function createQueryBuilder(): QueryBuilder { - return $this->client->getConnection()->createQueryBuilder(); + return $this->dbal->createQueryBuilder(); } private function addSubtreeTagConstraints(QueryBuilder $queryBuilder, string $hierarchyRelationTableAlias = 'h'): void @@ -748,7 +748,7 @@ private function fetchCteResults(QueryBuilder $queryBuilderInitial, QueryBuilder $parameters = array_merge($queryBuilderInitial->getParameters(), $queryBuilderRecursive->getParameters(), $queryBuilderCte->getParameters()); $parameterTypes = array_merge($queryBuilderInitial->getParameterTypes(), $queryBuilderRecursive->getParameterTypes(), $queryBuilderCte->getParameterTypes()); try { - return $this->client->getConnection()->fetchAllAssociative($query, $parameters, $parameterTypes); + return $this->dbal->fetchAllAssociative($query, $parameters, $parameterTypes); } catch (DbalException $e) { throw new \RuntimeException(sprintf('Failed to fetch CTE result: %s', $e->getMessage()), 1678358108, $e); } @@ -760,7 +760,7 @@ private function fetchCteCountResult(QueryBuilder $queryBuilderInitial, QueryBui $parameters = array_merge($queryBuilderInitial->getParameters(), $queryBuilderRecursive->getParameters(), $queryBuilderCte->getParameters()); $parameterTypes = array_merge($queryBuilderInitial->getParameterTypes(), $queryBuilderRecursive->getParameterTypes(), $queryBuilderCte->getParameterTypes()); try { - return (int)$this->client->getConnection()->fetchOne($query, $parameters, $parameterTypes); + return (int)$this->dbal->fetchOne($query, $parameters, $parameterTypes); } catch (DbalException $e) { throw new \RuntimeException(sprintf('Failed to fetch CTE count result: %s', $e->getMessage()), 1679047841, $e); } diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ProjectionContentGraph.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ProjectionContentGraph.php index 2c7f005bd23..22e858a201c 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ProjectionContentGraph.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ProjectionContentGraph.php @@ -25,7 +25,6 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Node\NodeName; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; @@ -41,8 +40,8 @@ class ProjectionContentGraph { public function __construct( - private readonly DbalClientInterface $client, - private readonly ContentGraphTableNames $tableNames + private readonly Connection $dbal, + private readonly ContentGraphTableNames $tableNames, ) { } @@ -71,7 +70,7 @@ public function findParentNode( ? $coveredDimensionSpacePoint->hash : $originDimensionSpacePoint->hash ]; - $nodeRow = $this->getDatabaseConnection()->executeQuery( + $nodeRow = $this->dbal->executeQuery( 'SELECT p.*, ph.contentstreamid, ph.subtreetags, dsp.dimensionspacepoint AS origindimensionspacepoint FROM ' . $this->tableNames->node() . ' p INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' ph ON ph.childnodeanchor = p.relationanchorpoint INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' ch ON ch.parentnodeanchor = p.relationanchorpoint @@ -102,7 +101,7 @@ public function findNodeInAggregate( NodeAggregateId $nodeAggregateId, DimensionSpacePoint $coveredDimensionSpacePoint ): ?NodeRecord { - $nodeRow = $this->getDatabaseConnection()->executeQuery( + $nodeRow = $this->dbal->executeQuery( 'SELECT n.*, h.subtreetags, dsp.dimensionspacepoint AS origindimensionspacepoint FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h ON h.childnodeanchor = n.relationanchorpoint INNER JOIN ' . $this->tableNames->dimensionSpacePoints() . ' dsp ON n.origindimensionspacepointhash = dsp.hash @@ -131,7 +130,7 @@ public function getAnchorPointForNodeAndOriginDimensionSpacePointAndContentStrea OriginDimensionSpacePoint $originDimensionSpacePoint, ContentStreamId $contentStreamId ): ?NodeRelationAnchorPoint { - $rows = $this->getDatabaseConnection()->executeQuery( + $rows = $this->dbal->executeQuery( 'SELECT DISTINCT n.relationanchorpoint FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h ON h.childnodeanchor = n.relationanchorpoint WHERE n.nodeaggregateid = :nodeAggregateId @@ -166,7 +165,7 @@ public function getAnchorPointsForNodeAggregateInContentStream( NodeAggregateId $nodeAggregateId, ContentStreamId $contentStreamId ): iterable { - $rows = $this->getDatabaseConnection()->executeQuery( + $rows = $this->dbal->executeQuery( 'SELECT DISTINCT n.relationanchorpoint FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->hierarchyRelation() . ' h ON h.childnodeanchor = n.relationanchorpoint WHERE n.nodeaggregateid = :nodeAggregateId @@ -190,7 +189,7 @@ public function getAnchorPointsForNodeAggregateInContentStream( */ public function getNodeByAnchorPoint(NodeRelationAnchorPoint $nodeRelationAnchorPoint): ?NodeRecord { - $nodeRow = $this->getDatabaseConnection()->executeQuery( + $nodeRow = $this->dbal->executeQuery( 'SELECT n.*, dsp.dimensionspacepoint AS origindimensionspacepoint FROM ' . $this->tableNames->node() . ' n INNER JOIN ' . $this->tableNames->dimensionSpacePoints() . ' dsp ON n.origindimensionspacepointhash = dsp.hash WHERE n.relationanchorpoint = :relationAnchorPoint', @@ -226,7 +225,7 @@ public function determineHierarchyRelationPosition( } if ($succeedingSiblingAnchorPoint) { /** @var array $succeedingSiblingRelation */ - $succeedingSiblingRelation = $this->getDatabaseConnection()->executeQuery( + $succeedingSiblingRelation = $this->dbal->executeQuery( 'SELECT h.* FROM ' . $this->tableNames->hierarchyRelation() . ' h WHERE h.childnodeanchor = :succeedingSiblingAnchorPoint AND h.contentstreamid = :contentStreamId @@ -241,7 +240,7 @@ public function determineHierarchyRelationPosition( $succeedingSiblingPosition = (int)$succeedingSiblingRelation['position']; $parentAnchorPoint = NodeRelationAnchorPoint::fromInteger($succeedingSiblingRelation['parentnodeanchor']); - $precedingSiblingData = $this->getDatabaseConnection()->executeQuery( + $precedingSiblingData = $this->dbal->executeQuery( 'SELECT MAX(h.position) AS position FROM ' . $this->tableNames->hierarchyRelation() . ' h WHERE h.parentnodeanchor = :anchorPoint AND h.contentstreamid = :contentStreamId @@ -267,7 +266,7 @@ public function determineHierarchyRelationPosition( } else { if (!$parentAnchorPoint) { /** @var array $childHierarchyRelationData */ - $childHierarchyRelationData = $this->getDatabaseConnection()->executeQuery( + $childHierarchyRelationData = $this->dbal->executeQuery( 'SELECT h.parentnodeanchor FROM ' . $this->tableNames->hierarchyRelation() . ' h WHERE h.childnodeanchor = :childAnchorPoint AND h.contentstreamid = :contentStreamId @@ -282,7 +281,7 @@ public function determineHierarchyRelationPosition( $childHierarchyRelationData['parentnodeanchor'] ); } - $rightmostSucceedingSiblingRelationData = $this->getDatabaseConnection()->executeQuery( + $rightmostSucceedingSiblingRelationData = $this->dbal->executeQuery( 'SELECT MAX(h.position) AS position FROM ' . $this->tableNames->hierarchyRelation() . ' h WHERE h.parentnodeanchor = :parentAnchorPoint AND h.contentstreamid = :contentStreamId @@ -319,7 +318,7 @@ public function getOutgoingHierarchyRelationsForNodeAndSubgraph( ): array { $relations = []; foreach ( - $this->getDatabaseConnection()->executeQuery( + $this->dbal->executeQuery( 'SELECT h.* FROM ' . $this->tableNames->hierarchyRelation() . ' h WHERE h.parentnodeanchor = :parentAnchorPoint AND h.contentstreamid = :contentStreamId @@ -351,7 +350,7 @@ public function getIngoingHierarchyRelationsForNodeAndSubgraph( ): array { $relations = []; foreach ( - $this->getDatabaseConnection()->executeQuery( + $this->dbal->executeQuery( 'SELECT h.* FROM ' . $this->tableNames->hierarchyRelation() . ' h WHERE h.childnodeanchor = :childAnchorPoint AND h.contentstreamid = :contentStreamId @@ -398,7 +397,7 @@ public function findIngoingHierarchyRelationsForNode( $types['dimensionSpacePointHashes'] = Connection::PARAM_STR_ARRAY; } foreach ( - $this->getDatabaseConnection()->executeQuery($query, $parameters, $types) + $this->dbal->executeQuery($query, $parameters, $types) ->fetchAllAssociative() as $relationData ) { $relations[$relationData['dimensionspacepointhash']] = $this->mapRawDataToHierarchyRelation($relationData); @@ -436,7 +435,7 @@ public function findOutgoingHierarchyRelationsForNode( $types['dimensionSpacePointHashes'] = Connection::PARAM_STR_ARRAY; } foreach ( - $this->getDatabaseConnection()->executeQuery($query, $parameters, $types) + $this->dbal->executeQuery($query, $parameters, $types) ->fetchAllAssociative() as $relationData ) { $relations[$relationData['dimensionspacepointhash']] = $this->mapRawDataToHierarchyRelation($relationData); @@ -459,7 +458,7 @@ public function findOutgoingHierarchyRelationsForNodeAggregate( ): array { $relations = []; foreach ( - $this->getDatabaseConnection()->executeQuery( + $this->dbal->executeQuery( 'SELECT h.* FROM ' . $this->tableNames->hierarchyRelation() . ' h INNER JOIN ' . $this->tableNames->node() . ' n ON h.parentnodeanchor = n.relationanchorpoint WHERE n.nodeaggregateid = :nodeAggregateId @@ -513,7 +512,7 @@ public function findIngoingHierarchyRelationsForNodeAggregate( } foreach ( - $this->getDatabaseConnection()->executeQuery($query, $parameters, $types) + $this->dbal->executeQuery($query, $parameters, $types) ->fetchAllAssociative() as $relationData ) { $relations[] = $this->mapRawDataToHierarchyRelation($relationData); @@ -531,7 +530,7 @@ public function getAllContentStreamIdsAnchorPointIsContainedIn( ): array { $contentStreamIds = []; foreach ( - $this->getDatabaseConnection()->executeQuery( + $this->dbal->executeQuery( 'SELECT DISTINCT h.contentstreamid FROM ' . $this->tableNames->hierarchyRelation() . ' h WHERE h.childnodeanchor = :nodeRelationAnchorPoint', @@ -551,7 +550,7 @@ public function getAllContentStreamIdsAnchorPointIsContainedIn( */ protected function mapRawDataToHierarchyRelation(array $rawData): HierarchyRelation { - $dimensionspacepointRaw = $this->client->getConnection()->fetchOne('SELECT dimensionspacepoint FROM ' . $this->tableNames->dimensionSpacePoints() . ' WHERE hash = :hash', ['hash' => $rawData['dimensionspacepointhash']]); + $dimensionspacepointRaw = $this->dbal->fetchOne('SELECT dimensionspacepoint FROM ' . $this->tableNames->dimensionSpacePoints() . ' WHERE hash = :hash', ['hash' => $rawData['dimensionspacepointhash']]); return new HierarchyRelation( NodeRelationAnchorPoint::fromInteger((int)$rawData['parentnodeanchor']), @@ -563,12 +562,4 @@ protected function mapRawDataToHierarchyRelation(array $rawData): HierarchyRelat NodeFactory::extractNodeTagsFromJson($rawData['subtreetags']), ); } - - /** - * @return Connection - */ - protected function getDatabaseConnection(): Connection - { - return $this->client->getConnection(); - } } diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/ContentHyperGraphFactory.php b/Neos.ContentGraph.PostgreSQLAdapter/src/ContentHyperGraphFactory.php index ebb74ab5035..55b8b529a80 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/ContentHyperGraphFactory.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/ContentHyperGraphFactory.php @@ -2,9 +2,9 @@ namespace Neos\ContentGraph\PostgreSQLAdapter; +use Doctrine\DBAL\Connection; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\ContentHypergraph; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\NodeFactory; -use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\ContentGraphFactoryInterface; use Neos\ContentRepository\Core\ContentGraphFinder; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; @@ -21,7 +21,7 @@ final readonly class ContentHyperGraphFactory implements ContentGraphFactoryInterface { public function __construct( - private PostgresDbalClientInterface $databaseClient, + private Connection $dbal, private NodeFactory $nodeFactory, private ContentRepositoryId $contentRepositoryId, private NodeTypeManager $nodeTypeManager, @@ -38,7 +38,7 @@ public function buildForWorkspace(WorkspaceName $workspaceName): ContentGraphInt 'Workspace' )); - $row = $this->databaseClient->getConnection()->executeQuery( + $row = $this->dbal->executeQuery( ' SELECT * FROM ' . $tableName . ' WHERE workspaceName = :workspaceName @@ -57,6 +57,6 @@ public function buildForWorkspace(WorkspaceName $workspaceName): ContentGraphInt public function buildForWorkspaceAndContentStream(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraphInterface { - return new ContentHyperGraph($this->databaseClient, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNamePrefix, $workspaceName, $contentStreamId); + return new ContentHyperGraph($this->dbal, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNamePrefix, $workspaceName, $contentStreamId); } } diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/HypergraphProjection.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/HypergraphProjection.php index 794b625b1cc..02da1b170cf 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/HypergraphProjection.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/HypergraphProjection.php @@ -26,7 +26,6 @@ use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Feature\NodeVariation; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Feature\SubtreeTagging; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\SchemaBuilder\HypergraphSchemaBuilder; -use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\ContentGraphFinder; use Neos\ContentRepository\Core\EventStore\EventInterface; use Neos\ContentRepository\Core\Feature\ContentStreamForking\Event\ContentStreamWasForked; @@ -72,13 +71,13 @@ final class HypergraphProjection implements ProjectionInterface private ProjectionHypergraph $projectionHypergraph; public function __construct( - private readonly PostgresDbalClientInterface $databaseClient, + private readonly Connection $dbal, private readonly string $tableNamePrefix, private readonly ContentGraphFinder $contentGraphFinder ) { - $this->projectionHypergraph = new ProjectionHypergraph($this->databaseClient, $this->tableNamePrefix); + $this->projectionHypergraph = new ProjectionHypergraph($this->dbal, $this->tableNamePrefix); $this->checkpointStorage = new DbalCheckpointStorage( - $this->databaseClient->getConnection(), + $this->dbal, $this->tableNamePrefix . '_checkpoint', self::class ); @@ -88,9 +87,9 @@ public function __construct( public function setUp(): void { foreach ($this->determineRequiredSqlStatements() as $statement) { - $this->getDatabaseConnection()->executeStatement($statement); + $this->dbal->executeStatement($statement); } - $this->getDatabaseConnection()->executeStatement(' + $this->dbal->executeStatement(' CREATE INDEX IF NOT EXISTS node_properties ON ' . $this->tableNamePrefix . '_node USING GIN(properties); create index if not exists hierarchy_children @@ -132,15 +131,14 @@ public function status(): ProjectionStatus */ private function determineRequiredSqlStatements(): array { - $connection = $this->databaseClient->getConnection(); - HypergraphSchemaBuilder::registerTypes($connection->getDatabasePlatform()); - $schemaManager = $connection->getSchemaManager(); + HypergraphSchemaBuilder::registerTypes($this->dbal->getDatabasePlatform()); + $schemaManager = $this->dbal->getSchemaManager(); if (!$schemaManager instanceof AbstractSchemaManager) { throw new \RuntimeException('Failed to retrieve Schema Manager', 1625653914); } $schema = (new HypergraphSchemaBuilder($this->tableNamePrefix))->buildSchema(); - return DbalSchemaDiff::determineRequiredSqlStatements($connection, $schema); + return DbalSchemaDiff::determineRequiredSqlStatements($this->dbal, $schema); } public function reset(): void @@ -153,11 +151,10 @@ public function reset(): void private function truncateDatabaseTables(): void { - $connection = $this->databaseClient->getConnection(); - $connection->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_node'); - $connection->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_hierarchyhyperrelation'); - $connection->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_referencerelation'); - $connection->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_restrictionhyperrelation'); + $this->dbal->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_node'); + $this->dbal->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_hierarchyhyperrelation'); + $this->dbal->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_referencerelation'); + $this->dbal->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_restrictionhyperrelation'); } public function canHandle(EventInterface $event): bool @@ -247,6 +244,6 @@ protected function transactional(\Closure $operations): void protected function getDatabaseConnection(): Connection { - return $this->databaseClient->getConnection(); + return $this->dbal; } } diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/ProjectionHypergraph.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/ProjectionHypergraph.php index 07359ca5709..b1c4d0e0f1e 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/ProjectionHypergraph.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/ProjectionHypergraph.php @@ -17,7 +17,6 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception as DBALException; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Query\ProjectionHypergraphQuery; -use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; @@ -32,8 +31,8 @@ final class ProjectionHypergraph { public function __construct( - private readonly PostgresDbalClientInterface $databaseClient, - private readonly string $tableNamePrefix + private readonly Connection $dbal, + private readonly string $tableNamePrefix, ) { } @@ -55,7 +54,7 @@ public function findNodeRecordByRelationAnchorPoint( 'relationAnchorPoint' => $relationAnchorPoint->value ]; - $result = $this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchAssociative(); + $result = $this->dbal->executeQuery($query, $parameters)->fetchAssociative(); return $result ? NodeRecord::fromDatabaseRow($result) : null; } @@ -71,7 +70,7 @@ public function findNodeRecordByCoverage( $query = ProjectionHypergraphQuery::create($contentStreamId, $this->tableNamePrefix); $query = $query->withDimensionSpacePoint($dimensionSpacePoint) ->withNodeAggregateId($nodeAggregateId); - $result = $query->execute($this->getDatabaseConnection())->fetchAssociative(); + $result = $query->execute($this->dbal)->fetchAssociative(); return $result ? NodeRecord::fromDatabaseRow($result) : null; } @@ -88,7 +87,7 @@ public function findNodeRecordByOrigin( $query = $query->withOriginDimensionSpacePoint($originDimensionSpacePoint); $query = $query->withNodeAggregateId($nodeAggregateId); - $result = $query->execute($this->getDatabaseConnection())->fetchAssociative(); + $result = $query->execute($this->dbal)->fetchAssociative(); return $result ? NodeRecord::fromDatabaseRow($result) : null; } @@ -118,7 +117,7 @@ public function findParentNodeRecordByOrigin( 'childNodeAggregateId' => $childNodeAggregateId->value ]; - $result = $this->getDatabaseConnection() + $result = $this->dbal ->executeQuery($query, $parameters) ->fetchAssociative(); @@ -171,7 +170,7 @@ public function findParentNodeRecordByCoverage( 'childNodeAggregateId' => $childNodeAggregateId->value ]; - $result = $this->getDatabaseConnection() + $result = $this->dbal ->executeQuery($query, $parameters) ->fetchAssociative(); @@ -189,7 +188,7 @@ public function findNodeRecordsForNodeAggregate( $query = ProjectionHypergraphQuery::create($contentStreamId, $this->tableNamePrefix); $query = $query->withNodeAggregateId($nodeAggregateId); - $result = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $result = $query->execute($this->dbal)->fetchAllAssociative(); return array_map(function ($row) { return NodeRecord::fromDatabaseRow($row); @@ -224,7 +223,7 @@ public function findIngoingHierarchyHyperrelationRecords( } $hierarchyHyperrelations = []; - foreach ($this->getDatabaseConnection()->executeQuery($query, $parameters, $types) as $row) { + foreach ($this->dbal->executeQuery($query, $parameters, $types) as $row) { $hierarchyHyperrelations[] = HierarchyHyperrelationRecord::fromDatabaseRow($row); } @@ -259,7 +258,7 @@ public function findOutgoingHierarchyHyperrelationRecords( $types['affectedDimensionSpacePointHashes'] = Connection::PARAM_STR_ARRAY; $hierarchyHyperrelations = []; - foreach ($this->getDatabaseConnection()->executeQuery($query, $parameters, $types) as $row) { + foreach ($this->dbal->executeQuery($query, $parameters, $types) as $row) { $hierarchyHyperrelations[] = HierarchyHyperrelationRecord::fromDatabaseRow($row); } @@ -283,7 +282,7 @@ public function findOutgoingReferenceHyperrelationRecords( ]; $referenceHyperrelations = []; - foreach ($this->getDatabaseConnection()->executeQuery($query, $parameters) as $row) { + foreach ($this->dbal->executeQuery($query, $parameters) as $row) { $referenceHyperrelations[] = ReferenceRelationRecord::fromDatabaseRow($row); } @@ -312,7 +311,7 @@ public function findHierarchyHyperrelationRecordByParentNodeAnchor( 'parentNodeAnchor' => $parentNodeAnchor->value ]; - $result = $this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchAssociative(); + $result = $this->dbal->executeQuery($query, $parameters)->fetchAssociative(); return $result ? HierarchyHyperrelationRecord::fromDatabaseRow($result) : null; } @@ -339,7 +338,7 @@ public function findHierarchyHyperrelationRecordByChildNodeAnchor( 'childNodeAnchor' => $childNodeAnchor->value ]; - $result = $this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchAssociative(); + $result = $this->dbal->executeQuery($query, $parameters)->fetchAssociative(); return $result ? HierarchyHyperrelationRecord::fromDatabaseRow($result) : null; } @@ -362,7 +361,7 @@ public function findHierarchyHyperrelationRecordsByChildNodeAnchor( ]; $hierarchyRelationRecords = []; - $result = $this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchAllAssociative(); + $result = $this->dbal->executeQuery($query, $parameters)->fetchAllAssociative(); foreach ($result as $row) { $hierarchyRelationRecords[] = HierarchyHyperrelationRecord::fromDatabaseRow($row); } @@ -393,7 +392,7 @@ public function findChildHierarchyHyperrelationRecord( 'dimensionSpacePointHash' => $dimensionSpacePoint->hash ]; - $result = $this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchAssociative(); + $result = $this->dbal->executeQuery($query, $parameters)->fetchAssociative(); return $result ? HierarchyHyperrelationRecord::fromDatabaseRow($result) : null; } @@ -421,7 +420,7 @@ public function findCoverageByNodeRelationAnchorPoint( ]; $dimensionSpacePoints = []; - foreach ($this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchAllAssociative() as $row) { + foreach ($this->dbal->executeQuery($query, $parameters)->fetchAllAssociative() as $row) { $dimensionSpacePoints[] = DimensionSpacePoint::fromJsonString($row['dimensionspacepoint']); } @@ -451,7 +450,7 @@ public function findCoverageByNodeAggregateId( ]; $dimensionSpacePoints = []; - foreach ($this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchAllAssociative() as $row) { + foreach ($this->dbal->executeQuery($query, $parameters)->fetchAllAssociative() as $row) { $dimensionSpacePoints[] = DimensionSpacePoint::fromJsonString($row['dimensionspacepoint']); } @@ -489,7 +488,7 @@ public function findOutgoingRestrictionRelations( $restrictionRelationRecords = []; foreach ( - $this->getDatabaseConnection()->executeQuery($query, $parameters, $types) + $this->dbal->executeQuery($query, $parameters, $types) ->fetchAllAssociative() as $row ) { $restrictionRelationRecords[] = RestrictionHyperrelationRecord::fromDatabaseRow($row); @@ -522,7 +521,7 @@ public function findIngoingRestrictionRelations( ]; $restrictionRelations = []; - $rows = $this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchAllAssociative(); + $rows = $this->dbal->executeQuery($query, $parameters)->fetchAllAssociative(); foreach ($rows as $row) { $restrictionRelations[] = RestrictionHyperrelationRecord::fromDatabaseRow($row); } @@ -589,7 +588,7 @@ public function findDescendantNodeAggregateIds( 'affectedDimensionSpacePointHashes' => Connection::PARAM_STR_ARRAY ]; - $rows = $this->getDatabaseConnection()->executeQuery($query, $parameters, $types) + $rows = $this->dbal->executeQuery($query, $parameters, $types) ->fetchAllAssociative(); $nodeAggregateIdsByDimensionSpacePoint = []; foreach ($rows as $row) { @@ -614,11 +613,6 @@ public function countContentStreamCoverage(NodeRelationAnchorPoint $anchorPoint) 'anchorPoint' => $anchorPoint->value ]; - return (int)$this->getDatabaseConnection()->executeQuery($query, $parameters)->rowCount(); - } - - protected function getDatabaseConnection(): Connection - { - return $this->databaseClient->getConnection(); + return (int)$this->dbal->executeQuery($query, $parameters)->rowCount(); } } diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentHypergraph.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentHypergraph.php index 8ed8bc21557..25a70995cd5 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentHypergraph.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentHypergraph.php @@ -14,11 +14,10 @@ namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository; -use Doctrine\DBAL\Connection as DatabaseConnection; +use Doctrine\DBAL\Connection; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\HypergraphChildQuery; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\HypergraphParentQuery; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\HypergraphQuery; -use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; @@ -46,26 +45,20 @@ */ final class ContentHypergraph implements ContentGraphInterface { - private PostgresDbalClientInterface $databaseClient; - - private NodeFactory $nodeFactory; - /** * @var array|ContentSubhypergraph[] */ private array $subhypergraphs; public function __construct( - PostgresDbalClientInterface $databaseClient, - NodeFactory $nodeFactory, + private readonly Connection $dbal, + private readonly NodeFactory $nodeFactory, private readonly ContentRepositoryId $contentRepositoryId, private readonly NodeTypeManager $nodeTypeManager, private readonly string $tableNamePrefix, public readonly WorkspaceName $workspaceName, public readonly ContentStreamId $contentStreamId ) { - $this->databaseClient = $databaseClient; - $this->nodeFactory = $nodeFactory; } public function getContentRepositoryId(): ContentRepositoryId @@ -90,7 +83,7 @@ public function getSubgraph( $this->workspaceName, $dimensionSpacePoint, $visibilityConstraints, - $this->databaseClient, + $this->dbal, $this->nodeFactory, $this->nodeTypeManager, $this->tableNamePrefix @@ -149,7 +142,7 @@ public function findNodeAggregateById( $query = HypergraphQuery::create($this->contentStreamId, $this->tableNamePrefix, true); $query = $query->withNodeAggregateId($nodeAggregateId); - $nodeRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $nodeRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapNodeRowsToNodeAggregate( $nodeRows, @@ -184,7 +177,7 @@ public function findParentNodeAggregateByChildOriginDimensionSpacePoint( 'childOriginDimensionSpacePointHash' => $childOriginDimensionSpacePoint->hash ]; - $nodeRows = $this->getDatabaseConnection()->executeQuery( + $nodeRows = $this->dbal->executeQuery( $query, $parameters )->fetchAllAssociative(); @@ -204,7 +197,7 @@ public function findParentNodeAggregates( $query = HypergraphParentQuery::create($this->contentStreamId, $this->tableNamePrefix); $query = $query->withChildNodeAggregateId($childNodeAggregateId); - $nodeRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $nodeRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapNodeRowsToNodeAggregates( $nodeRows, @@ -224,7 +217,7 @@ public function findChildNodeAggregates( $this->tableNamePrefix ); - $nodeRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $nodeRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapNodeRowsToNodeAggregates( $nodeRows, @@ -243,7 +236,7 @@ public function findChildNodeAggregateByName( ); $query = $query->withChildNodeName($name); - $nodeRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $nodeRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapNodeRowsToNodeAggregate( $nodeRows, @@ -264,7 +257,7 @@ public function findTetheredChildNodeAggregates( ); $query = $query->withOnlyTethered(); - $nodeRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $nodeRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapNodeRowsToNodeAggregates($nodeRows, VisibilityConstraints::withoutRestrictions()); } @@ -286,7 +279,7 @@ public function getDimensionSpacePointsOccupiedByChildNodeName( ->withDimensionSpacePoints($dimensionSpacePointsToCheck); $occupiedDimensionSpacePoints = []; - foreach ($query->execute($this->getDatabaseConnection())->fetchAllAssociative() as $row) { + foreach ($query->execute($this->dbal)->fetchAllAssociative() as $row) { $occupiedDimensionSpacePoints[$row['dimensionspacepointhash']] = DimensionSpacePoint::fromJsonString($row['dimensionspacepoint']); } @@ -302,7 +295,7 @@ public function countNodes(): int { $query = 'SELECT COUNT(*) FROM ' . $this->tableNamePrefix . '_node'; - return $this->getDatabaseConnection()->executeQuery($query)->fetchOne(); + return $this->dbal->executeQuery($query)->fetchOne(); } /** @@ -313,11 +306,6 @@ public function findUsedNodeTypeNames(): iterable return []; } - private function getDatabaseConnection(): DatabaseConnection - { - return $this->databaseClient->getConnection(); - } - public function getContentStreamId(): ContentStreamId { return $this->contentStreamId; diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentSubhypergraph.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentSubhypergraph.php index 19aac2de5cb..b7971989a59 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentSubhypergraph.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentSubhypergraph.php @@ -14,6 +14,7 @@ namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection as DatabaseConnection; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\HypergraphChildQuery; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\HypergraphParentQuery; @@ -22,12 +23,10 @@ use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\HypergraphSiblingQuery; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\HypergraphSiblingQueryMode; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\QueryUtility; -use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath; -use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindBackReferencesFilter; @@ -80,7 +79,7 @@ public function __construct( private WorkspaceName $workspaceName, private DimensionSpacePoint $dimensionSpacePoint, private VisibilityConstraints $visibilityConstraints, - private PostgresDbalClientInterface $databaseClient, + private Connection $dbal, private NodeFactory $nodeFactory, private NodeTypeManager $nodeTypeManager, private string $tableNamePrefix @@ -114,7 +113,7 @@ public function findNodeById(NodeAggregateId $nodeAggregateId): ?Node ->withNodeAggregateId($nodeAggregateId) ->withRestriction($this->visibilityConstraints); - $nodeRow = $query->execute($this->getDatabaseConnection())->fetchAssociative(); + $nodeRow = $query->execute($this->dbal)->fetchAssociative(); return $nodeRow ? $this->nodeFactory->mapNodeRowToNode( $nodeRow, @@ -131,7 +130,7 @@ public function findRootNodeByType(NodeTypeName $nodeTypeName): ?Node ->withClassification(NodeAggregateClassification::CLASSIFICATION_ROOT) ->withRestriction($this->visibilityConstraints); - $nodeRow = $query->execute($this->getDatabaseConnection())->fetchAssociative(); + $nodeRow = $query->execute($this->dbal)->fetchAssociative(); return $nodeRow ? $this->nodeFactory->mapNodeRowToNode( $nodeRow, @@ -164,7 +163,7 @@ public function findChildNodes( ->withOffset($filter->pagination->offset); } - $childNodeRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $childNodeRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapNodeRowsToNodes( $childNodeRows, @@ -201,7 +200,7 @@ public function findReferences( $orderings[] = 'r.position'; $query = $query->orderedBy($orderings); - $referenceRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $referenceRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapReferenceRowsToReferences( $referenceRows, @@ -251,7 +250,7 @@ public function findBackReferences( ->withOffset($filter->pagination->offset); } - $referenceRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $referenceRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapReferenceRowsToReferences( $referenceRows, @@ -272,7 +271,7 @@ public function findParentNode(NodeAggregateId $childNodeAggregateId): ?Node ->withRestriction($this->visibilityConstraints) ->withChildNodeAggregateId($childNodeAggregateId); - $nodeRow = $query->execute($this->getDatabaseConnection())->fetchAssociative(); + $nodeRow = $query->execute($this->dbal)->fetchAssociative(); return $nodeRow ? $this->nodeFactory->mapNodeRowToNode( $nodeRow, @@ -314,7 +313,7 @@ private function findChildNodeConnectedThroughEdgeName( ->withRestriction($this->visibilityConstraints) ->withChildNodeName($nodeName); - $nodeRow = $query->execute($this->getDatabaseConnection())->fetchAssociative(); + $nodeRow = $query->execute($this->dbal)->fetchAssociative(); return $nodeRow ? $this->nodeFactory->mapNodeRowToNode( $nodeRow, @@ -375,7 +374,7 @@ private function findAnySiblings( ->withOffset($pagination->offset); } - $siblingsRows = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); + $siblingsRows = $query->execute($this->dbal)->fetchAllAssociative(); return $this->nodeFactory->mapNodeRowsToNodes($siblingsRows, $this->visibilityConstraints); } @@ -462,7 +461,7 @@ public function findSubtree( - $nodeRows = $this->getDatabaseConnection()->executeQuery($query, $parameters, $types) + $nodeRows = $this->dbal->executeQuery($query, $parameters, $types) ->fetchAllAssociative(); if ($nodeRows === []) { return null; @@ -523,7 +522,7 @@ public function countNodes(): int 'dimensionSpacePointHash' => $this->dimensionSpacePoint->hash ]; - $result = $this->getDatabaseConnection()->executeQuery($query, $parameters)->fetchNumeric(); + $result = $this->dbal->executeQuery($query, $parameters)->fetchNumeric(); return $result ? $result[0] : 0; } @@ -541,11 +540,6 @@ private function findNodeByPathFromStartingNode(NodePath $path, Node $startingNo return $currentNode; } - private function getDatabaseConnection(): DatabaseConnection - { - return $this->databaseClient->getConnection(); - } - /** * @return array */ diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/HypergraphProjectionFactory.php b/Neos.ContentGraph.PostgreSQLAdapter/src/HypergraphProjectionFactory.php index 3f8189c6d01..db6af1347ba 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/HypergraphProjectionFactory.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/HypergraphProjectionFactory.php @@ -4,9 +4,9 @@ namespace Neos\ContentGraph\PostgreSQLAdapter; +use Doctrine\DBAL\Connection; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\HypergraphProjection; use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\NodeFactory; -use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\ContentGraphFinder; use Neos\ContentRepository\Core\Factory\ProjectionFactoryDependencies; use Neos\ContentRepository\Core\Projection\ProjectionFactoryInterface; @@ -19,7 +19,7 @@ final class HypergraphProjectionFactory implements ProjectionFactoryInterface { public function __construct( - private readonly PostgresDbalClientInterface $dbalClient + private readonly Connection $dbal, ) { } @@ -44,9 +44,9 @@ public function build( ); return new HypergraphProjection( - $this->dbalClient, + $this->dbal, $tableNamePrefix, - new ContentGraphFinder(new ContentHyperGraphFactory($this->dbalClient, $nodeFactory, $projectionFactoryDependencies->contentRepositoryId, $projectionFactoryDependencies->nodeTypeManager, $tableNamePrefix)) + new ContentGraphFinder(new ContentHyperGraphFactory($this->dbal, $nodeFactory, $projectionFactoryDependencies->contentRepositoryId, $projectionFactoryDependencies->nodeTypeManager, $tableNamePrefix)) ); } } diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Infrastructure/PostgresDbalClientInterface.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Infrastructure/PostgresDbalClientInterface.php deleted file mode 100644 index a77e88ce4d2..00000000000 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Infrastructure/PostgresDbalClientInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -dbalClient = $this->getObject(DbalClientInterface::class); + $this->dbal = $this->getObject(Connection::class); $this->setUpInterleavingLogger(); $this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class); } diff --git a/Neos.ContentRepository.Core/Classes/Infrastructure/DbalClientInterface.php b/Neos.ContentRepository.Core/Classes/Infrastructure/DbalClientInterface.php deleted file mode 100644 index 93e1aff18f3..00000000000 --- a/Neos.ContentRepository.Core/Classes/Infrastructure/DbalClientInterface.php +++ /dev/null @@ -1,17 +0,0 @@ -client->getConnection(); - $contentStreamIds = $connection->executeQuery('SELECT contentstreamid FROM ' . $this->tableName)->fetchFirstColumn(); + $contentStreamIds = $this->dbal->executeQuery('SELECT contentstreamid FROM ' . $this->tableName)->fetchFirstColumn(); return array_map(ContentStreamId::fromString(...), $contentStreamIds); } @@ -78,8 +76,7 @@ public function findUnusedContentStreams(bool $findTemporaryContentStreams): ite $states[] = ContentStreamState::STATE_FORKED; } - $connection = $this->client->getConnection(); - $contentStreamIds = $connection->executeQuery( + $contentStreamIds = $this->dbal->executeQuery( ' SELECT contentstreamid FROM ' . $this->tableName . ' WHERE removed = FALSE @@ -101,9 +98,8 @@ public function findUnusedContentStreams(bool $findTemporaryContentStreams): ite public function findStateForContentStream(ContentStreamId $contentStreamId): ?ContentStreamState { - $connection = $this->client->getConnection(); /* @var $state string|false */ - $state = $connection->executeQuery( + $state = $this->dbal->executeQuery( ' SELECT state FROM ' . $this->tableName . ' WHERE contentstreamid = :contentStreamId @@ -122,8 +118,7 @@ public function findStateForContentStream(ContentStreamId $contentStreamId): ?Co */ public function findUnusedAndRemovedContentStreams(): iterable { - $connection = $this->client->getConnection(); - $contentStreamIds = $connection->executeQuery( + $contentStreamIds = $this->dbal->executeQuery( ' WITH RECURSIVE transitiveUsedContentStreams (contentstreamid) AS ( -- initial case: find all content streams currently in direct use by a workspace @@ -161,9 +156,8 @@ public function findUnusedAndRemovedContentStreams(): iterable public function findVersionForContentStream(ContentStreamId $contentStreamId): MaybeVersion { - $connection = $this->client->getConnection(); /* @var $state string|false */ - $version = $connection->executeQuery( + $version = $this->dbal->executeQuery( ' SELECT version FROM ' . $this->tableName . ' WHERE contentStreamId = :contentStreamId @@ -182,9 +176,8 @@ public function findVersionForContentStream(ContentStreamId $contentStreamId): M public function hasContentStream(ContentStreamId $contentStreamId): bool { - $connection = $this->client->getConnection(); /* @var $state string|false */ - $version = $connection->executeQuery( + $version = $this->dbal->executeQuery( ' SELECT version FROM ' . $this->tableName . ' WHERE contentStreamId = :contentStreamId diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentStream/ContentStreamProjection.php b/Neos.ContentRepository.Core/Classes/Projection/ContentStream/ContentStreamProjection.php index 0878d3fe1cd..b362bdb5b66 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentStream/ContentStreamProjection.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentStream/ContentStreamProjection.php @@ -38,7 +38,6 @@ use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Event\WorkspaceRebaseFailed; use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Event\WorkspaceWasRebased; use Neos\ContentRepository\Core\Infrastructure\DbalCheckpointStorage; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Infrastructure\DbalSchemaDiff; use Neos\ContentRepository\Core\Infrastructure\DbalSchemaFactory; use Neos\ContentRepository\Core\Projection\CheckpointStorageInterface; @@ -67,11 +66,11 @@ class ContentStreamProjection implements ProjectionInterface private DbalCheckpointStorage $checkpointStorage; public function __construct( - private readonly DbalClientInterface $dbalClient, + private readonly Connection $dbal, private readonly string $tableName ) { $this->checkpointStorage = new DbalCheckpointStorage( - $this->dbalClient->getConnection(), + $this->dbal, $this->tableName . '_checkpoint', self::class ); @@ -81,12 +80,12 @@ public function setUp(): void { $statements = $this->determineRequiredSqlStatements(); // MIGRATIONS - if ($this->getDatabaseConnection()->getSchemaManager()->tablesExist([$this->tableName])) { + if ($this->dbal->getSchemaManager()->tablesExist([$this->tableName])) { // added 2023-04-01 $statements[] = sprintf("UPDATE %s SET state='FORKED' WHERE state='REBASING'; ", $this->tableName); } foreach ($statements as $statement) { - $this->getDatabaseConnection()->executeStatement($statement); + $this->dbal->executeStatement($statement); } $this->checkpointStorage->setUp(); } @@ -101,7 +100,7 @@ public function status(): ProjectionStatus return ProjectionStatus::setupRequired($checkpointStorageStatus->details); } try { - $this->getDatabaseConnection()->connect(); + $this->dbal->connect(); } catch (\Throwable $e) { return ProjectionStatus::error(sprintf('Failed to connect to database: %s', $e->getMessage())); } @@ -121,8 +120,7 @@ public function status(): ProjectionStatus */ private function determineRequiredSqlStatements(): array { - $connection = $this->dbalClient->getConnection(); - $schemaManager = $connection->getSchemaManager(); + $schemaManager = $this->dbal->getSchemaManager(); if (!$schemaManager instanceof AbstractSchemaManager) { throw new \RuntimeException('Failed to retrieve Schema Manager', 1625653914); } @@ -138,12 +136,12 @@ private function determineRequiredSqlStatements(): array ])) ]); - return DbalSchemaDiff::determineRequiredSqlStatements($connection, $schema); + return DbalSchemaDiff::determineRequiredSqlStatements($this->dbal, $schema); } public function reset(): void { - $this->getDatabaseConnection()->executeStatement('TRUNCATE table ' . $this->tableName); + $this->dbal->executeStatement('TRUNCATE table ' . $this->tableName); $this->checkpointStorage->acquireLock(); $this->checkpointStorage->updateAndReleaseLock(SequenceNumber::none()); } @@ -203,7 +201,7 @@ public function getState(): ProjectionStateInterface { if (!$this->contentStreamFinder) { $this->contentStreamFinder = new ContentStreamFinder( - $this->dbalClient, + $this->dbal, $this->tableName ); } @@ -212,7 +210,7 @@ public function getState(): ProjectionStateInterface private function whenContentStreamWasCreated(ContentStreamWasCreated $event, EventEnvelope $eventEnvelope): void { - $this->getDatabaseConnection()->insert($this->tableName, [ + $this->dbal->insert($this->tableName, [ 'contentStreamId' => $event->contentStreamId->value, 'version' => self::extractVersion($eventEnvelope), 'state' => ContentStreamState::STATE_CREATED->value, @@ -239,7 +237,7 @@ private function whenWorkspaceWasCreated(WorkspaceWasCreated $event): void private function whenContentStreamWasForked(ContentStreamWasForked $event, EventEnvelope $eventEnvelope): void { - $this->getDatabaseConnection()->insert($this->tableName, [ + $this->dbal->insert($this->tableName, [ 'contentStreamId' => $event->newContentStreamId->value, 'version' => self::extractVersion($eventEnvelope), 'sourceContentStreamId' => $event->sourceContentStreamId->value, @@ -336,7 +334,7 @@ private function whenContentStreamWasClosed(ContentStreamWasClosed $event, Event $event->contentStreamId, ContentStreamState::STATE_CLOSED, ); - $this->getDatabaseConnection()->update($this->tableName, [ + $this->dbal->update($this->tableName, [ 'version' => self::extractVersion($eventEnvelope), ], [ 'contentStreamId' => $event->contentStreamId->value @@ -349,7 +347,7 @@ private function whenContentStreamWasReopened(ContentStreamWasReopened $event, E $event->contentStreamId, $event->previousState, ); - $this->getDatabaseConnection()->update($this->tableName, [ + $this->dbal->update($this->tableName, [ 'version' => self::extractVersion($eventEnvelope), ], [ 'contentStreamId' => $event->contentStreamId->value @@ -358,7 +356,7 @@ private function whenContentStreamWasReopened(ContentStreamWasReopened $event, E private function whenContentStreamWasRemoved(ContentStreamWasRemoved $event, EventEnvelope $eventEnvelope): void { - $this->getDatabaseConnection()->update($this->tableName, [ + $this->dbal->update($this->tableName, [ 'removed' => true, 'version' => self::extractVersion($eventEnvelope), ], [ @@ -368,7 +366,7 @@ private function whenContentStreamWasRemoved(ContentStreamWasRemoved $event, Eve private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded $event, EventEnvelope $eventEnvelope): void { - $this->getDatabaseConnection()->update($this->tableName, [ + $this->dbal->update($this->tableName, [ 'version' => self::extractVersion($eventEnvelope), ], [ 'contentStreamId' => $event->contentStreamId->value @@ -377,23 +375,18 @@ private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded private function updateStateForContentStream(ContentStreamId $contentStreamId, ContentStreamState $state): void { - $this->getDatabaseConnection()->update($this->tableName, [ + $this->dbal->update($this->tableName, [ 'state' => $state->value, ], [ 'contentStreamId' => $contentStreamId->value ]); } - private function getDatabaseConnection(): Connection - { - return $this->dbalClient->getConnection(); - } - private function updateContentStreamVersion( EmbedsContentStreamAndNodeAggregateId $eventInstance, EventEnvelope $eventEnvelope ): void { - $this->getDatabaseConnection()->update($this->tableName, [ + $this->dbal->update($this->tableName, [ 'version' => self::extractVersion($eventEnvelope), ], [ 'contentStreamId' => $eventInstance->getContentStreamId()->value diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentStream/ContentStreamProjectionFactory.php b/Neos.ContentRepository.Core/Classes/Projection/ContentStream/ContentStreamProjectionFactory.php index 4df27962c82..a7fa2c6bcd5 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentStream/ContentStreamProjectionFactory.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentStream/ContentStreamProjectionFactory.php @@ -14,8 +14,8 @@ namespace Neos\ContentRepository\Core\Projection\ContentStream; +use Doctrine\DBAL\Connection; use Neos\ContentRepository\Core\Factory\ProjectionFactoryDependencies; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Projection\ProjectionFactoryInterface; /** @@ -25,7 +25,7 @@ class ContentStreamProjectionFactory implements ProjectionFactoryInterface { public function __construct( - private readonly DbalClientInterface $dbalClient + private readonly Connection $dbal, ) { } @@ -39,7 +39,7 @@ public function build( (new \ReflectionClass(ContentStreamProjection::class))->getShortName() )); return new ContentStreamProjection( - $this->dbalClient, + $this->dbal, sprintf( 'cr_%s_p_%s', $projectionFactoryDependencies->contentRepositoryId->value, diff --git a/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceFinder.php b/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceFinder.php index 724b3c4ab84..4ec004a9cce 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceFinder.php +++ b/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceFinder.php @@ -14,7 +14,7 @@ namespace Neos\ContentRepository\Core\Projection\Workspace; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; +use Doctrine\DBAL\Connection; use Neos\ContentRepository\Core\Projection\ProjectionStateInterface; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceDescription; @@ -29,7 +29,7 @@ final class WorkspaceFinder implements ProjectionStateInterface { public function __construct( - private readonly DbalClientInterface $client, + private readonly Connection $dbal, private readonly WorkspaceRuntimeCache $workspaceRuntimeCache, private readonly string $tableName ) { @@ -43,8 +43,7 @@ public function findOneByName(WorkspaceName $name): ?Workspace return $workspace; } - $connection = $this->client->getConnection(); - $workspaceRow = $connection->executeQuery( + $workspaceRow = $this->dbal->executeQuery( ' SELECT * FROM ' . $this->tableName . ' WHERE workspaceName = :workspaceName @@ -71,8 +70,7 @@ public function findOneByCurrentContentStreamId( return $workspace; } - $connection = $this->client->getConnection(); - $workspaceRow = $connection->executeQuery( + $workspaceRow = $this->dbal->executeQuery( ' SELECT * FROM ' . $this->tableName . ' WHERE currentContentStreamId = :currentContentStreamId @@ -99,8 +97,7 @@ public function findByBaseWorkspace(WorkspaceName $baseWorkspace): array { $result = []; - $connection = $this->client->getConnection(); - $workspaceRows = $connection->executeQuery( + $workspaceRows = $this->dbal->executeQuery( ' SELECT * FROM ' . $this->tableName . ' WHERE baseWorkspaceName = :workspaceName @@ -120,8 +117,7 @@ public function findByBaseWorkspace(WorkspaceName $baseWorkspace): array public function findOneByWorkspaceOwner(string $owner): ?Workspace { - $connection = $this->client->getConnection(); - $workspaceRow = $connection->executeQuery( + $workspaceRow = $this->dbal->executeQuery( ' SELECT * FROM ' . $this->tableName . ' WHERE workspaceOwner = :workspaceOwner @@ -142,8 +138,7 @@ public function findAll(): Workspaces { $result = []; - $connection = $this->client->getConnection(); - $workspaceRows = $connection->executeQuery( + $workspaceRows = $this->dbal->executeQuery( ' SELECT * FROM ' . $this->tableName . ' ' @@ -166,8 +161,7 @@ public function findOutdated(): array { $result = []; - $connection = $this->client->getConnection(); - $workspaceRows = $connection->executeQuery( + $workspaceRows = $this->dbal->executeQuery( ' SELECT * FROM ' . $this->tableName . ' WHERE status = :outdated ', diff --git a/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceProjection.php b/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceProjection.php index ac526c6576f..a069f587577 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceProjection.php +++ b/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceProjection.php @@ -34,7 +34,6 @@ use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Event\WorkspaceRebaseFailed; use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Event\WorkspaceWasRebased; use Neos\ContentRepository\Core\Infrastructure\DbalCheckpointStorage; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Infrastructure\DbalSchemaDiff; use Neos\ContentRepository\Core\Infrastructure\DbalSchemaFactory; use Neos\ContentRepository\Core\Projection\CheckpointStorageStatusType; @@ -63,11 +62,11 @@ class WorkspaceProjection implements ProjectionInterface, WithMarkStaleInterface private WorkspaceRuntimeCache $workspaceRuntimeCache; public function __construct( - private readonly DbalClientInterface $dbalClient, + private readonly Connection $dbal, private readonly string $tableName, ) { $this->checkpointStorage = new DbalCheckpointStorage( - $this->dbalClient->getConnection(), + $this->dbal, $this->tableName . '_checkpoint', self::class ); @@ -77,7 +76,7 @@ public function __construct( public function setUp(): void { foreach ($this->determineRequiredSqlStatements() as $statement) { - $this->getDatabaseConnection()->executeStatement($statement); + $this->dbal->executeStatement($statement); } $this->checkpointStorage->setUp(); } @@ -92,7 +91,7 @@ public function status(): ProjectionStatus return ProjectionStatus::setupRequired($checkpointStorageStatus->details); } try { - $this->getDatabaseConnection()->connect(); + $this->dbal->connect(); } catch (\Throwable $e) { return ProjectionStatus::error(sprintf('Failed to connect to database: %s', $e->getMessage())); } @@ -112,8 +111,7 @@ public function status(): ProjectionStatus */ private function determineRequiredSqlStatements(): array { - $connection = $this->dbalClient->getConnection(); - $schemaManager = $connection->getSchemaManager(); + $schemaManager = $this->dbal->getSchemaManager(); if (!$schemaManager instanceof AbstractSchemaManager) { throw new \RuntimeException('Failed to retrieve Schema Manager', 1625653914); } @@ -130,12 +128,12 @@ private function determineRequiredSqlStatements(): array $workspaceTable->setPrimaryKey(['workspacename']); $schema = DbalSchemaFactory::createSchemaWithTables($schemaManager, [$workspaceTable]); - return DbalSchemaDiff::determineRequiredSqlStatements($connection, $schema); + return DbalSchemaDiff::determineRequiredSqlStatements($this->dbal, $schema); } public function reset(): void { - $this->getDatabaseConnection()->exec('TRUNCATE ' . $this->tableName); + $this->dbal->exec('TRUNCATE ' . $this->tableName); $this->checkpointStorage->acquireLock(); $this->checkpointStorage->updateAndReleaseLock(SequenceNumber::none()); } @@ -186,7 +184,7 @@ public function getState(): WorkspaceFinder { if (!$this->workspaceFinder) { $this->workspaceFinder = new WorkspaceFinder( - $this->dbalClient, + $this->dbal, $this->workspaceRuntimeCache, $this->tableName ); @@ -201,7 +199,7 @@ public function markStale(): void private function whenWorkspaceWasCreated(WorkspaceWasCreated $event): void { - $this->getDatabaseConnection()->insert($this->tableName, [ + $this->dbal->insert($this->tableName, [ 'workspaceName' => $event->workspaceName->value, 'baseWorkspaceName' => $event->baseWorkspaceName->value, 'workspaceTitle' => $event->workspaceTitle->value, @@ -214,7 +212,7 @@ private function whenWorkspaceWasCreated(WorkspaceWasCreated $event): void private function whenWorkspaceWasRenamed(WorkspaceWasRenamed $event): void { - $this->getDatabaseConnection()->update( + $this->dbal->update( $this->tableName, [ 'workspaceTitle' => $event->workspaceTitle->value, @@ -226,7 +224,7 @@ private function whenWorkspaceWasRenamed(WorkspaceWasRenamed $event): void private function whenRootWorkspaceWasCreated(RootWorkspaceWasCreated $event): void { - $this->getDatabaseConnection()->insert($this->tableName, [ + $this->dbal->insert($this->tableName, [ 'workspaceName' => $event->workspaceName->value, 'workspaceTitle' => $event->workspaceTitle->value, 'workspaceDescription' => $event->workspaceDescription->value, @@ -298,7 +296,7 @@ private function whenWorkspaceRebaseFailed(WorkspaceRebaseFailed $event): void private function whenWorkspaceWasRemoved(WorkspaceWasRemoved $event): void { - $this->getDatabaseConnection()->delete( + $this->dbal->delete( $this->tableName, ['workspaceName' => $event->workspaceName->value] ); @@ -306,7 +304,7 @@ private function whenWorkspaceWasRemoved(WorkspaceWasRemoved $event): void private function whenWorkspaceOwnerWasChanged(WorkspaceOwnerWasChanged $event): void { - $this->getDatabaseConnection()->update( + $this->dbal->update( $this->tableName, ['workspaceOwner' => $event->newWorkspaceOwner], ['workspaceName' => $event->workspaceName->value] @@ -315,7 +313,7 @@ private function whenWorkspaceOwnerWasChanged(WorkspaceOwnerWasChanged $event): private function whenWorkspaceBaseWorkspaceWasChanged(WorkspaceBaseWorkspaceWasChanged $event): void { - $this->getDatabaseConnection()->update( + $this->dbal->update( $this->tableName, [ 'baseWorkspaceName' => $event->baseWorkspaceName->value, @@ -329,7 +327,7 @@ private function updateContentStreamId( ContentStreamId $contentStreamId, WorkspaceName $workspaceName, ): void { - $this->getDatabaseConnection()->update($this->tableName, [ + $this->dbal->update($this->tableName, [ 'currentContentStreamId' => $contentStreamId->value, ], [ 'workspaceName' => $workspaceName->value @@ -338,7 +336,7 @@ private function updateContentStreamId( private function markWorkspaceAsUpToDate(WorkspaceName $workspaceName): void { - $this->getDatabaseConnection()->executeUpdate(' + $this->dbal->executeUpdate(' UPDATE ' . $this->tableName . ' SET status = :upToDate WHERE @@ -351,7 +349,7 @@ private function markWorkspaceAsUpToDate(WorkspaceName $workspaceName): void private function markDependentWorkspacesAsOutdated(WorkspaceName $baseWorkspaceName): void { - $this->getDatabaseConnection()->executeUpdate(' + $this->dbal->executeUpdate(' UPDATE ' . $this->tableName . ' SET status = :outdated WHERE @@ -364,7 +362,7 @@ private function markDependentWorkspacesAsOutdated(WorkspaceName $baseWorkspaceN private function markWorkspaceAsOutdated(WorkspaceName $workspaceName): void { - $this->getDatabaseConnection()->executeUpdate(' + $this->dbal->executeUpdate(' UPDATE ' . $this->tableName . ' SET status = :outdated @@ -378,7 +376,7 @@ private function markWorkspaceAsOutdated(WorkspaceName $workspaceName): void private function markWorkspaceAsOutdatedConflict(WorkspaceName $workspaceName): void { - $this->getDatabaseConnection()->executeUpdate(' + $this->dbal->executeUpdate(' UPDATE ' . $this->tableName . ' SET status = :outdatedConflict @@ -389,9 +387,4 @@ private function markWorkspaceAsOutdatedConflict(WorkspaceName $workspaceName): 'workspaceName' => $workspaceName->value ]); } - - private function getDatabaseConnection(): Connection - { - return $this->dbalClient->getConnection(); - } } diff --git a/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceProjectionFactory.php b/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceProjectionFactory.php index e0c47662ec5..094ee2e4e56 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceProjectionFactory.php +++ b/Neos.ContentRepository.Core/Classes/Projection/Workspace/WorkspaceProjectionFactory.php @@ -14,8 +14,8 @@ namespace Neos\ContentRepository\Core\Projection\Workspace; +use Doctrine\DBAL\Connection; use Neos\ContentRepository\Core\Factory\ProjectionFactoryDependencies; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Projection\ProjectionFactoryInterface; /** @@ -25,7 +25,7 @@ class WorkspaceProjectionFactory implements ProjectionFactoryInterface { public function __construct( - private readonly DbalClientInterface $dbalClient + private readonly Connection $dbal, ) { } @@ -39,7 +39,7 @@ public function build( (new \ReflectionClass(WorkspaceProjection::class))->getShortName() )); return new WorkspaceProjection( - $this->dbalClient, + $this->dbal, sprintf( 'cr_%s_p_%s', $projectionFactoryDependencies->contentRepositoryId->value, diff --git a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Classes/DoctrineDbalClient.php b/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Classes/DoctrineDbalClient.php deleted file mode 100644 index 47a3e5dec97..00000000000 --- a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Classes/DoctrineDbalClient.php +++ /dev/null @@ -1,66 +0,0 @@ - - */ - protected $backendOptions; - - /** - * @Flow\InjectConfiguration(package="Neos.Flow", path="persistence.doctrine.sqlLogger") - * @var string - */ - protected $sqlLoggerName; - - /** - * @var Connection - */ - protected $connection; - - public function initializeObject(): void - { - $configuration = new Configuration(); - if (!empty($this->sqlLoggerName)) { - /** @var SQLLogger $configuredSqlLogger */ - $configuredSqlLogger = new $this->sqlLoggerName(); - $configuration->setSQLLogger($configuredSqlLogger); - } - $this->connection = DriverManager::getConnection($this->backendOptions, $configuration); - } - - public function getConnection(): Connection - { - if (!$this->connection->isConnected()) { - $this->connection->connect(); - } - - return $this->connection; - } -} diff --git a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Caches.yaml b/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Caches.yaml deleted file mode 100644 index 19b4e1c3b8f..00000000000 --- a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Caches.yaml +++ /dev/null @@ -1,5 +0,0 @@ -Neos_ContentGraph_DoctrineDbalAdapter_ProcessedEvents: - frontend: Neos\Cache\Frontend\VariableFrontend - backend: Neos\Cache\Backend\FileBackend - backendOptions: - defaultLifetime: 400 diff --git a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Objects.yaml b/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Objects.yaml deleted file mode 100644 index 1dfd0f4d332..00000000000 --- a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Objects.yaml +++ /dev/null @@ -1,11 +0,0 @@ -Neos\ContentRepository\Core\Infrastructure\DbalClientInterface: - className: 'Neos\ContentRepositoryRegistry\DoctrineDbalClient\DoctrineDbalClient' - -Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjectionFactory: - scope: singleton - factoryObjectName: 'Neos\ContentRepositoryRegistry\Infrastructure\GenericObjectFactory' - arguments: - 1: - value: 'Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjectionFactory' - 2: - object: 'Neos\ContentRepository\Core\Infrastructure\DbalClientInterface' diff --git a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Settings.yaml b/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Settings.yaml deleted file mode 100644 index 2c39ca34a96..00000000000 --- a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/Configuration/Settings.yaml +++ /dev/null @@ -1,9 +0,0 @@ -Neos: - ContentRepositoryRegistry: - presets: - 'default': - projections: - # NOTE: the following name must be stable, because we use it f.e. in Neos UI to register - # catchUpHooks for content cache flushing - 'Neos.ContentRepository:ContentGraph': - factoryObjectName: Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjectionFactory diff --git a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/composer.json b/Neos.ContentRepositoryRegistry.DoctrineDbalClient/composer.json deleted file mode 100644 index b7653be7e81..00000000000 --- a/Neos.ContentRepositoryRegistry.DoctrineDbalClient/composer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "neos/contentrepositoryregistry-doctrinedbalclient", - "type": "neos-package", - "description": "Doctrine DBAL client for the Neos Content Repository Registry", - "license": [ - "GPL-3.0-or-later" - ], - "require": { - "neos/flow": "^9.0", - "neos/contentrepository-core": "self.version", - "neos/contentrepositoryregistry": "self.version", - "neos/contentgraph-doctrinedbaladapter": "self.version" - }, - "provide": { - "neos/contentrepositoryregistry-storageclient": "self.version" - }, - "autoload": { - "psr-4": { - "Neos\\ContentRepositoryRegistry\\DoctrineDbalClient\\": "Classes" - } - } -} diff --git a/Neos.ContentRepositoryRegistry.PostgresDbalClient/Classes/PostgresDbalClient.php b/Neos.ContentRepositoryRegistry.PostgresDbalClient/Classes/PostgresDbalClient.php deleted file mode 100644 index e9ac4790333..00000000000 --- a/Neos.ContentRepositoryRegistry.PostgresDbalClient/Classes/PostgresDbalClient.php +++ /dev/null @@ -1,64 +0,0 @@ - - */ - protected array $backendOptions = []; - - /** - * @Flow\InjectConfiguration(package="Neos.Flow", path="persistence.doctrine.sqlLogger") - * @var string|null - */ - protected ?string $sqlLogger; - - protected Connection $connection; - - public function initializeObject(): void - { - $configuration = new Configuration(); - if (!empty($this->sqlLogger)) { - $configuredSqlLoggerName = $this->sqlLogger; - /** @var SQLLogger $configuredSqlLogger */ - $configuredSqlLogger = new $configuredSqlLoggerName(); - $configuration->setSQLLogger($configuredSqlLogger); - } - $this->connection = DriverManager::getConnection($this->backendOptions, $configuration); - } - - public function getConnection(): Connection - { - if (!$this->connection->isConnected()) { - $this->connection->connect(); - } - - return $this->connection; - } -} diff --git a/Neos.ContentRepositoryRegistry.PostgresDbalClient/Configuration/Caches.yaml b/Neos.ContentRepositoryRegistry.PostgresDbalClient/Configuration/Caches.yaml deleted file mode 100644 index 056a5694303..00000000000 --- a/Neos.ContentRepositoryRegistry.PostgresDbalClient/Configuration/Caches.yaml +++ /dev/null @@ -1,5 +0,0 @@ -Neos_ContentGraph_PostgreSQLAdapter_ProcessedEvents: - frontend: Neos\Cache\Frontend\VariableFrontend - backend: Neos\Cache\Backend\FileBackend - backendOptions: - defaultLifetime: 400 diff --git a/Neos.ContentRepositoryRegistry.PostgresDbalClient/Configuration/Objects.yaml b/Neos.ContentRepositoryRegistry.PostgresDbalClient/Configuration/Objects.yaml deleted file mode 100644 index 5df3f8c0715..00000000000 --- a/Neos.ContentRepositoryRegistry.PostgresDbalClient/Configuration/Objects.yaml +++ /dev/null @@ -1,8 +0,0 @@ -Neos\ContentGraph\PostgreSQLAdapter\HypergraphProjectionFactory: - scope: singleton - factoryObjectName: Neos\ContentRepositoryRegistry\Infrastructure\GenericObjectFactory - arguments: - 1: - value: Neos\ContentGraph\PostgreSQLAdapter\HypergraphProjectionFactory - 2: - object: 'Neos\ContentRepositoryRegistry\PostgresDbalClient\PostgresDbalClient' diff --git a/Neos.ContentRepositoryRegistry.PostgresDbalClient/composer.json b/Neos.ContentRepositoryRegistry.PostgresDbalClient/composer.json deleted file mode 100644 index 57348e01009..00000000000 --- a/Neos.ContentRepositoryRegistry.PostgresDbalClient/composer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "neos/contentrepositoryregistry-postgresdbalclient", - "type": "neos-package", - "description": "PostgreSQL-optimized Doctrine DBAL client for the Neos Content Repository Registry", - "license": [ - "GPL-3.0-or-later" - ], - "require": { - "neos/flow": "^9.0", - "neos/contentrepository-core": "self.version", - "neos/contentrepositoryregistry": "self.version", - "neos/contentgraph-postgresqladapter": "self.version" - }, - "provide": { - "neos/contentrepositoryregistry-storageclient": "self.version" - }, - "autoload": { - "psr-4": { - "Neos\\ContentRepositoryRegistry\\PostgresDbalClient\\": "Classes" - } - } -} diff --git a/Neos.ContentRepositoryRegistry/Classes/Command/ContentGraphIntegrityCommandController.php b/Neos.ContentRepositoryRegistry/Classes/Command/ContentGraphIntegrityCommandController.php index 71683ca6422..604ac1d1f9f 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Command/ContentGraphIntegrityCommandController.php +++ b/Neos.ContentRepositoryRegistry/Classes/Command/ContentGraphIntegrityCommandController.php @@ -11,8 +11,8 @@ * source code. */ +use Doctrine\DBAL\Connection; use Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Error\Messages\Result; @@ -25,7 +25,7 @@ final class ContentGraphIntegrityCommandController extends CommandController private const OUTPUT_MODE_LOG = 'log'; #[Flow\Inject()] - protected DbalClientInterface $dbalClient; + protected Connection $dbal; #[Flow\Inject()] protected ContentRepositoryRegistry $contentRepositoryRegistry; @@ -34,7 +34,7 @@ public function runViolationDetectionCommand(string $contentRepository = 'defaul { $detectionRunner = $this->contentRepositoryRegistry->buildService( ContentRepositoryId::fromString($contentRepository), - new DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory($this->dbalClient) + new DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory($this->dbal) ); $outputMode = $this->resolveOutputMode($outputMode); diff --git a/Neos.ContentRepositoryRegistry/Configuration/Objects.yaml b/Neos.ContentRepositoryRegistry/Configuration/Objects.yaml index 854fb3dc508..113f828b6d6 100644 --- a/Neos.ContentRepositoryRegistry/Configuration/Objects.yaml +++ b/Neos.ContentRepositoryRegistry/Configuration/Objects.yaml @@ -11,7 +11,7 @@ Neos\ContentRepository\Core\Projection\ContentStream\ContentStreamProjectionFact 1: value: Neos\ContentRepository\Core\Projection\ContentStream\ContentStreamProjectionFactory 2: - object: 'Neos\ContentRepository\Core\Infrastructure\DbalClientInterface' + object: 'Doctrine\DBAL\Connection' Neos\ContentRepository\Core\Projection\Workspace\WorkspaceProjectionFactory: scope: singleton @@ -20,4 +20,14 @@ Neos\ContentRepository\Core\Projection\Workspace\WorkspaceProjectionFactory: 1: value: Neos\ContentRepository\Core\Projection\Workspace\WorkspaceProjectionFactory 2: - object: 'Neos\ContentRepository\Core\Infrastructure\DbalClientInterface' + object: 'Doctrine\DBAL\Connection' + +# This adds a soft-dependency to the neos/contentgraph-doctrinedbaladapter package +Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjectionFactory: + scope: singleton + factoryObjectName: 'Neos\ContentRepositoryRegistry\Infrastructure\GenericObjectFactory' + arguments: + 1: + value: 'Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjectionFactory' + 2: + object: 'Doctrine\DBAL\Connection' diff --git a/Neos.ContentRepositoryRegistry/Configuration/Settings.yaml b/Neos.ContentRepositoryRegistry/Configuration/Settings.yaml index 37d72c41045..355f22e13d2 100644 --- a/Neos.ContentRepositoryRegistry/Configuration/Settings.yaml +++ b/Neos.ContentRepositoryRegistry/Configuration/Settings.yaml @@ -73,13 +73,7 @@ Neos: factoryObjectName: Neos\ContentRepository\Core\Projection\ContentStream\ContentStreamProjectionFactory 'Neos.ContentRepository:Workspace': factoryObjectName: Neos\ContentRepository\Core\Projection\Workspace\WorkspaceProjectionFactory - # NOTE: the following name must be stable, because we use it f.e. in Neos UI to register - # catchUpHooks for content cache flushing - #'Neos.ContentRepository:ContentGraph': - # factoryObjectName: Neos\ContentGraph\…Adapter\…ContentGraphProjectionFactory - - - - - - + # NOTE: the following name must be stable, because we use it f.e. in Neos UI to register catchUpHooks for content cache flushing + 'Neos.ContentRepository:ContentGraph': + # NOTE: This introduces a soft-dependency to the neos/contentgraph-doctrinedbaladapter package, but it can be overridden when a different adapter is used + factoryObjectName: Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjectionFactory diff --git a/Neos.Neos/Classes/PendingChangesProjection/ChangeFinder.php b/Neos.Neos/Classes/PendingChangesProjection/ChangeFinder.php index 0bc48c0e98b..ef797900572 100644 --- a/Neos.Neos/Classes/PendingChangesProjection/ChangeFinder.php +++ b/Neos.Neos/Classes/PendingChangesProjection/ChangeFinder.php @@ -14,7 +14,7 @@ namespace Neos\Neos\PendingChangesProjection; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; +use Doctrine\DBAL\Connection; use Neos\ContentRepository\Core\Projection\ProjectionStateInterface; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\Flow\Annotations as Flow; @@ -28,12 +28,9 @@ */ final class ChangeFinder implements ProjectionStateInterface { - /** - * @param DbalClientInterface $client - */ public function __construct( - private readonly DbalClientInterface $client, - private readonly string $tableName + private readonly Connection $dbal, + private readonly string $tableName, ) { } @@ -43,8 +40,7 @@ public function __construct( */ public function findByContentStreamId(ContentStreamId $contentStreamId): array { - $connection = $this->client->getConnection(); - $changeRows = $connection->executeQuery( + $changeRows = $this->dbal->executeQuery( ' SELECT * FROM ' . $this->tableName . ' WHERE contentStreamId = :contentStreamId @@ -62,8 +58,7 @@ public function findByContentStreamId(ContentStreamId $contentStreamId): array public function countByContentStreamId(ContentStreamId $contentStreamId): int { - $connection = $this->client->getConnection(); - return (int)$connection->executeQuery( + return (int)$this->dbal->executeQuery( ' SELECT * FROM ' . $this->tableName . ' WHERE contentStreamId = :contentStreamId diff --git a/Neos.Neos/Classes/PendingChangesProjection/ChangeProjection.php b/Neos.Neos/Classes/PendingChangesProjection/ChangeProjection.php index a4568f635bf..b07e92f7f9b 100644 --- a/Neos.Neos/Classes/PendingChangesProjection/ChangeProjection.php +++ b/Neos.Neos/Classes/PendingChangesProjection/ChangeProjection.php @@ -37,7 +37,6 @@ use Neos\ContentRepository\Core\Feature\SubtreeTagging\Event\SubtreeWasUntagged; use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Event\RootWorkspaceWasCreated; use Neos\ContentRepository\Core\Infrastructure\DbalCheckpointStorage; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Infrastructure\DbalSchemaDiff; use Neos\ContentRepository\Core\Infrastructure\DbalSchemaFactory; use Neos\ContentRepository\Core\Projection\CheckpointStorageStatusType; @@ -70,11 +69,11 @@ class ChangeProjection implements ProjectionInterface private DbalCheckpointStorage $checkpointStorage; public function __construct( - private readonly DbalClientInterface $dbalClient, + private readonly Connection $dbal, private readonly string $tableNamePrefix, ) { $this->checkpointStorage = new DbalCheckpointStorage( - $this->dbalClient->getConnection(), + $this->dbal, $this->tableNamePrefix . '_checkpoint', self::class ); @@ -84,7 +83,7 @@ public function __construct( public function setUp(): void { foreach ($this->determineRequiredSqlStatements() as $statement) { - $this->getDatabaseConnection()->executeStatement($statement); + $this->dbal->executeStatement($statement); } $this->checkpointStorage->setUp(); } @@ -99,7 +98,7 @@ public function status(): ProjectionStatus return ProjectionStatus::setupRequired($checkpointStorageStatus->details); } try { - $this->getDatabaseConnection()->connect(); + $this->dbal->connect(); } catch (\Throwable $e) { return ProjectionStatus::error(sprintf('Failed to connect to database: %s', $e->getMessage())); } @@ -119,7 +118,7 @@ public function status(): ProjectionStatus */ private function determineRequiredSqlStatements(): array { - $connection = $this->dbalClient->getConnection(); + $connection = $this->dbal; $schemaManager = $connection->getSchemaManager(); if (!$schemaManager instanceof AbstractSchemaManager) { throw new \RuntimeException('Failed to retrieve Schema Manager', 1625653914); @@ -156,8 +155,8 @@ private function determineRequiredSqlStatements(): array public function reset(): void { - $this->getDatabaseConnection()->exec('TRUNCATE ' . $this->tableNamePrefix); - $this->getDatabaseConnection()->exec('TRUNCATE ' . $this->tableNamePrefix . '_livecontentstreams'); + $this->dbal->exec('TRUNCATE ' . $this->tableNamePrefix); + $this->dbal->exec('TRUNCATE ' . $this->tableNamePrefix . '_livecontentstreams'); $this->checkpointStorage->acquireLock(); $this->checkpointStorage->updateAndReleaseLock(SequenceNumber::none()); } @@ -208,7 +207,7 @@ public function getState(): ChangeFinder { if (!$this->changeFinder) { $this->changeFinder = new ChangeFinder( - $this->dbalClient, + $this->dbal, $this->tableNamePrefix ); } @@ -218,7 +217,7 @@ public function getState(): ChangeFinder private function whenRootWorkspaceWasCreated(RootWorkspaceWasCreated $event): void { try { - $this->getDatabaseConnection()->insert($this->tableNamePrefix . '_livecontentstreams', [ + $this->dbal->insert($this->tableNamePrefix . '_livecontentstreams', [ 'contentStreamId' => $event->newContentStreamId->value, 'workspaceName' => $event->workspaceName->value, ]); @@ -308,7 +307,7 @@ private function whenNodeAggregateWasRemoved(NodeAggregateWasRemoved $event): vo return; } - $this->getDatabaseConnection()->executeUpdate( + $this->dbal->executeUpdate( 'DELETE FROM ' . $this->tableNamePrefix . ' WHERE contentStreamId = :contentStreamId @@ -327,7 +326,7 @@ private function whenNodeAggregateWasRemoved(NodeAggregateWasRemoved $event): vo ); foreach ($event->affectedOccupiedDimensionSpacePoints as $occupiedDimensionSpacePoint) { - $this->getDatabaseConnection()->executeUpdate( + $this->dbal->executeUpdate( 'INSERT INTO ' . $this->tableNamePrefix . ' (contentStreamId, nodeAggregateId, originDimensionSpacePoint, originDimensionSpacePointHash, created, deleted, changed, moved, removalAttachmentPoint) @@ -358,7 +357,7 @@ private function whenNodeAggregateWasRemoved(NodeAggregateWasRemoved $event): vo private function whenDimensionSpacePointWasMoved(DimensionSpacePointWasMoved $event): void { $this->transactional(function () use ($event) { - $this->getDatabaseConnection()->executeStatement( + $this->dbal->executeStatement( ' UPDATE ' . $this->tableNamePrefix . ' c SET @@ -473,10 +472,10 @@ private function modifyChange( if ($change === null) { $change = new Change($contentStreamId, $nodeAggregateId, $originDimensionSpacePoint, false, false, false, false); $modifyFn($change); - $change->addToDatabase($this->getDatabaseConnection(), $this->tableNamePrefix); + $change->addToDatabase($this->dbal, $this->tableNamePrefix); } else { $modifyFn($change); - $change->updateToDatabase($this->getDatabaseConnection(), $this->tableNamePrefix); + $change->updateToDatabase($this->dbal, $this->tableNamePrefix); } }); } @@ -486,7 +485,7 @@ private function getChange( NodeAggregateId $nodeAggregateId, OriginDimensionSpacePoint $originDimensionSpacePoint, ): ?Change { - $changeRow = $this->getDatabaseConnection()->executeQuery( + $changeRow = $this->dbal->executeQuery( 'SELECT n.* FROM ' . $this->tableNamePrefix . ' n WHERE n.contentStreamId = :contentStreamId AND n.nodeAggregateId = :nodeAggregateId @@ -504,21 +503,13 @@ private function getChange( private function transactional(\Closure $operations): void { - $this->getDatabaseConnection()->transactional($operations); - } - - /** - * @return Connection - */ - private function getDatabaseConnection(): Connection - { - return $this->dbalClient->getConnection(); + $this->dbal->transactional($operations); } private function isLiveContentStream(ContentStreamId $contentStreamId): bool { if ($this->liveContentStreamIdsRuntimeCache === null) { - $this->liveContentStreamIdsRuntimeCache = $this->getDatabaseConnection()->fetchFirstColumn('SELECT contentstreamid FROM ' . $this->tableNamePrefix . '_livecontentstreams'); + $this->liveContentStreamIdsRuntimeCache = $this->dbal->fetchFirstColumn('SELECT contentstreamid FROM ' . $this->tableNamePrefix . '_livecontentstreams'); } return in_array($contentStreamId->value, $this->liveContentStreamIdsRuntimeCache, true); } diff --git a/Neos.Neos/Classes/PendingChangesProjection/ChangeProjectionFactory.php b/Neos.Neos/Classes/PendingChangesProjection/ChangeProjectionFactory.php index ca5f1a2e8a7..8b231897d78 100644 --- a/Neos.Neos/Classes/PendingChangesProjection/ChangeProjectionFactory.php +++ b/Neos.Neos/Classes/PendingChangesProjection/ChangeProjectionFactory.php @@ -14,8 +14,8 @@ namespace Neos\Neos\PendingChangesProjection; +use Doctrine\DBAL\Connection; use Neos\ContentRepository\Core\Factory\ProjectionFactoryDependencies; -use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\Projection\ProjectionFactoryInterface; /** @@ -24,7 +24,7 @@ class ChangeProjectionFactory implements ProjectionFactoryInterface { public function __construct( - private readonly DbalClientInterface $dbalClient + private readonly Connection $dbal, ) { } @@ -33,7 +33,7 @@ public function build( array $options, ): ChangeProjection { return new ChangeProjection( - $this->dbalClient, + $this->dbal, sprintf( 'cr_%s_p_neos_change', $projectionFactoryDependencies->contentRepositoryId->value, diff --git a/composer.json b/composer.json index 8eb6f5248f6..f6d8da6e73e 100644 --- a/composer.json +++ b/composer.json @@ -64,8 +64,6 @@ "neos/contentrepository-nodemigration": "self.version", "neos/contentrepository-structureadjustment": "self.version", "neos/contentrepository-testsuite": "self.version", - "neos/contentrepositoryregistry-doctrinedbalclient": "self.version", - "neos/contentrepositoryregistry-postgresdbalclient": "self.version", "neos/contentrepositoryregistry-testsuite": "self.version", "neos/contentrepositoryregistry": "self.version", "neos/diff": "self.version", @@ -179,12 +177,6 @@ "Neos\\ContentRepository\\TestSuite\\": [ "Neos.ContentRepository.TestSuite/Classes" ], - "Neos\\ContentRepositoryRegistry\\DoctrineDbalClient\\": [ - "Neos.ContentRepositoryRegistry.DoctrineDbalClient/Classes" - ], - "Neos\\ContentRepositoryRegistry\\PostgresDbalClient\\": [ - "Neos.ContentRepositoryRegistry.PostgresDbalClient/Classes" - ], "Neos\\ContentRepositoryRegistry\\TestSuite\\": [ "Neos.ContentRepositoryRegistry.TestSuite/Classes" ],