Skip to content

Commit

Permalink
TASK: Raise doctrine/dbal version constraint
Browse files Browse the repository at this point in the history
Adjust to changes in DBAL API
  • Loading branch information
kitsunet committed Jul 1, 2024
1 parent f7e93b0 commit dd300bc
Show file tree
Hide file tree
Showing 29 changed files with 93 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use Behat\Gherkin\Node\TableNode;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames;
use Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory;
Expand Down Expand Up @@ -68,7 +68,7 @@ public function setupDbalGraphAdapterIntegrityViolationTrait()
/**
* @When /^I remove the following subtree tag:$/
* @param TableNode $payloadTable
* @throws DBALException
* @throws Exception
* @throws InvalidArgumentException
*/
public function iRemoveTheFollowingSubtreeTag(TableNode $payloadTable): void
Expand All @@ -91,7 +91,7 @@ public function iRemoveTheFollowingSubtreeTag(TableNode $payloadTable): void

/**
* @When /^I add the following hierarchy relation:$/
* @throws DBALException
* @throws Exception
*/
public function iAddTheFollowingHierarchyRelation(TableNode $payloadTable): void
{
Expand All @@ -106,7 +106,7 @@ public function iAddTheFollowingHierarchyRelation(TableNode $payloadTable): void
/**
* @When /^I change the following hierarchy relation's dimension space point hash:$/
* @param TableNode $payloadTable
* @throws DBALException
* @throws Exception
*/
public function iChangeTheFollowingHierarchyRelationsDimensionSpacePointHash(TableNode $payloadTable): void
{
Expand All @@ -126,7 +126,7 @@ public function iChangeTheFollowingHierarchyRelationsDimensionSpacePointHash(Tab
/**
* @When /^I change the following node's name:$/
* @param TableNode $payloadTable
* @throws DBALException
* @throws Exception
*/
public function iChangeTheFollowingNodesName(TableNode $payloadTable): void
{
Expand Down Expand Up @@ -159,7 +159,7 @@ public function iChangeTheFollowingNodesName(TableNode $payloadTable): void
/**
* @When /^I set the following position:$/
* @param TableNode $payloadTable
* @throws DBALException
* @throws Exception
*/
public function iSetTheFollowingPosition(TableNode $payloadTable): void
{
Expand All @@ -183,7 +183,7 @@ public function iSetTheFollowingPosition(TableNode $payloadTable): void
/**
* @When /^I detach the following reference relation from its source:$/
* @param TableNode $payloadTable
* @throws DBALException
* @throws Exception
*/
public function iDetachTheFollowingReferenceRelationFromItsSource(TableNode $payloadTable): void
{
Expand All @@ -201,7 +201,7 @@ public function iDetachTheFollowingReferenceRelationFromItsSource(TableNode $pay
/**
* @When /^I set the following reference position:$/
* @param TableNode $payloadTable
* @throws DBALException
* @throws Exception
*/
public function iSetTheFollowingReferencePosition(TableNode $payloadTable): void
{
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentGraph.DoctrineDbalAdapter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"require": {
"neos/contentrepository-core": "self.version",
"doctrine/dbal": "^2.13",
"doctrine/dbal": "^3.2",
"doctrine/migrations": "*"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Neos\ContentGraph\DoctrineDbalAdapter;

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

/**
* @param AbstractSchemaManager<AbstractPlatform> $schemaManager
* @return Schema
*/
public function buildSchema(AbstractSchemaManager $schemaManager): Schema
{
return DbalSchemaFactory::createSchemaWithTables($schemaManager, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function hierarchyIntegrityIsProvided(): Result
try {
$disconnectedHierarchyRelationRecords = $this->dbal->executeQuery($disconnectedHierarchyRelationStatement, [
'rootNodeAnchor' => NodeRelationAnchorPoint::forRootEdge()->value
]);
])->fetchAllAssociative();
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to load disconnected hierarchy relations: %s', $e->getMessage()), 1716491735, $e);
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public function siblingsAreDistinctlySorted(): Result
FROM {$this->tableNames->node()}
WHERE relationanchorpoint = :relationAnchorPoint
SQL;
foreach ($ambiguouslySortedHierarchyRelationRecords as $hierarchyRelationRecord) {
foreach ($ambiguouslySortedHierarchyRelationRecords->fetchAllAssociative() as $hierarchyRelationRecord) {
try {
$ambiguouslySortedNodeRecords = $this->dbal->fetchAllAssociative($ambiguouslySortedNodesStatement, [
'relationAnchorPoint' => $hierarchyRelationRecord['childnodeanchor']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ private function mapQueryBuilderToNodeAggregate(QueryBuilder $queryBuilder): ?No

/**
* @param QueryBuilder $queryBuilder
* @return iterable<NodeAggregate>
* @return \Traversable<NodeAggregate>
*/
private function mapQueryBuilderToNodeAggregates(QueryBuilder $queryBuilder): iterable
private function mapQueryBuilderToNodeAggregates(QueryBuilder $queryBuilder): \Traversable
{
return $this->nodeFactory->mapNodeRowsToNodeAggregates(
$this->fetchRows($queryBuilder),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
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;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Result;
use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames;
use Neos\ContentGraph\DoctrineDbalAdapter\NodeQueryBuilder;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
Expand Down Expand Up @@ -425,7 +424,7 @@ public function countNodes(): int
$queryBuilder = $this->nodeQueryBuilder->buildBasicNodeQuery($this->contentStreamId, $this->dimensionSpacePoint, 'n', 'COUNT(*)');
try {
$result = $this->executeQuery($queryBuilder)->fetchOne();
} catch (DbalDriverException | DbalException $e) {
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to count all nodes: %s', $e->getMessage()), 1678364741, $e);
}

Expand Down Expand Up @@ -659,23 +658,19 @@ private function applyPagination(QueryBuilder $queryBuilder, Pagination $paginat

/**
* @param QueryBuilder $queryBuilder
* @return Result<mixed>
* @return Result
* @throws DbalException
*/
private function executeQuery(QueryBuilder $queryBuilder): Result
{
$result = $queryBuilder->execute();
if (!$result instanceof Result) {
throw new \RuntimeException(sprintf('Expected instance of %s, got %s', Result::class, get_debug_type($result)), 1678370012);
}
return $result;
return $queryBuilder->executeQuery();
}

private function fetchNode(QueryBuilder $queryBuilder): ?Node
{
try {
$nodeRow = $this->executeQuery($queryBuilder)->fetchAssociative();
} catch (DbalDriverException | DbalException $e) {
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to fetch node: %s', $e->getMessage()), 1678286030, $e);
}
if ($nodeRow === false) {
Expand All @@ -694,7 +689,7 @@ private function fetchNodes(QueryBuilder $queryBuilder): Nodes
{
try {
$nodeRows = $this->executeQuery($queryBuilder)->fetchAllAssociative();
} catch (DbalDriverException | DbalException $e) {
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to fetch nodes: %s', $e->getMessage()), 1678292896, $e);
}
return $this->nodeFactory->mapNodeRowsToNodes(
Expand All @@ -710,7 +705,7 @@ private function fetchCount(QueryBuilder $queryBuilder): int
{
try {
return (int)$this->executeQuery($queryBuilder->select('COUNT(*)')->resetQueryPart('orderBy')->setFirstResult(0)->setMaxResults(1))->fetchOne();
} catch (DbalDriverException | DbalException $e) {
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to fetch count: %s', $e->getMessage()), 1679048349, $e);
}
}
Expand All @@ -719,7 +714,7 @@ private function fetchReferences(QueryBuilder $queryBuilder): References
{
try {
$referenceRows = $this->executeQuery($queryBuilder)->fetchAllAssociative();
} catch (DbalDriverException | DbalException $e) {
} catch (DbalException $e) {
throw new \RuntimeException(sprintf('Failed to fetch references: %s', $e->getMessage()), 1678364944, $e);
}
return $this->nodeFactory->mapReferenceRowsToReferences($referenceRows, $this->workspaceName, $this->contentStreamId, $this->dimensionSpacePoint, $this->visibilityConstraints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Traversable;

/**
* Implementation detail of ContentGraph and ContentSubgraph
Expand Down Expand Up @@ -241,15 +242,15 @@ public function mapNodeRowsToNodeAggregate(

/**
* @param iterable<int,array<string,string>> $nodeRows
* @return iterable<int,NodeAggregate>
* @return Traversable<int,NodeAggregate>
* @throws NodeTypeNotFound
*/
public function mapNodeRowsToNodeAggregates(
iterable $nodeRows,
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
VisibilityConstraints $visibilityConstraints
): iterable {
): Traversable {
$nodeTypeNames = [];
$nodeNames = [];
$occupiedDimensionSpacePointsByNodeAggregate = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Feature;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception as DbalException;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\EventCouldNotBeAppliedToContentGraph;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\HierarchyHyperrelationRecord;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\NodeRecord;
Expand Down Expand Up @@ -197,7 +198,7 @@ private function whenNodePeerVariantWasCreated(NodePeerVariantWasCreated $event)
}

/**
* @throws \Doctrine\DBAL\DBALException
* @throws DbalException
*/
protected function copyNodeToOriginDimensionSpacePoint(
NodeRecord $sourceNode,
Expand All @@ -219,7 +220,7 @@ protected function copyNodeToOriginDimensionSpacePoint(
}

/**
* @throws \Doctrine\DBAL\Exception
* @throws DbalException
*/
protected function replaceNodeRelationAnchorPoint(
ContentStreamId $contentStreamId,
Expand Down Expand Up @@ -346,7 +347,7 @@ protected function addMissingHierarchyRelations(
}

/**
* @throws \Doctrine\DBAL\Exception
* @throws DbalException
*/
protected function assignNewChildNodeToAffectedHierarchyRelations(
ContentStreamId $contentStreamId,
Expand All @@ -371,7 +372,7 @@ protected function assignNewChildNodeToAffectedHierarchyRelations(
}

/**
* @throws \Doctrine\DBAL\Exception
* @throws DbalException
*/
protected function assignNewParentNodeToAffectedHierarchyRelations(
ContentStreamId $contentStreamId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function findIngoingHierarchyHyperrelationRecords(
}

$hierarchyHyperrelations = [];
foreach ($this->dbal->executeQuery($query, $parameters, $types) as $row) {
foreach ($this->dbal->executeQuery($query, $parameters, $types)->fetchAllAssociative() as $row) {
$hierarchyHyperrelations[] = HierarchyHyperrelationRecord::fromDatabaseRow($row);
}

Expand Down Expand Up @@ -258,7 +258,7 @@ public function findOutgoingHierarchyHyperrelationRecords(
$types['affectedDimensionSpacePointHashes'] = Connection::PARAM_STR_ARRAY;

$hierarchyHyperrelations = [];
foreach ($this->dbal->executeQuery($query, $parameters, $types) as $row) {
foreach ($this->dbal->executeQuery($query, $parameters, $types)->fetchAllAssociative() as $row) {
$hierarchyHyperrelations[] = HierarchyHyperrelationRecord::fromDatabaseRow($row);
}

Expand All @@ -282,15 +282,14 @@ public function findOutgoingReferenceHyperrelationRecords(
];

$referenceHyperrelations = [];
foreach ($this->dbal->executeQuery($query, $parameters) as $row) {
foreach ($this->dbal->executeQuery($query, $parameters)->fetchAllAssociative() as $row) {
$referenceHyperrelations[] = ReferenceRelationRecord::fromDatabaseRow($row);
}

return $referenceHyperrelations;
}

/**
* @throws \Doctrine\DBAL\Driver\Exception
* @throws DBALException
*/
public function findHierarchyHyperrelationRecordByParentNodeAnchor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Query;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Types\Types;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Query;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Result;

/**
* The interface to be implemented by projection hypergraph queries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ForwardCompatibility\Result as QueryResult;
use Doctrine\DBAL\Result as QueryResult;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\ExpandedNodeTypeCriteria;

/**
Expand Down Expand Up @@ -97,14 +97,8 @@ public function getTypes(): array
return $this->types;
}

/**
* @return QueryResult&iterable<string, mixed>
*/
final public function execute(Connection $databaseConnection): QueryResult
{
/** @var QueryResult&iterable<string, mixed> $result */
$result = $databaseConnection->executeQuery($this->query, $this->parameters, $this->types);

return $result;
return $databaseConnection->executeQuery($this->query, $this->parameters, $this->types);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Result;

/**
* The interface to be implemented by hypergraph queries
Expand All @@ -25,7 +25,8 @@
interface HypergraphQueryInterface
{
/**
* @return ResultStatement<string,mixed>
* @param Connection $databaseConnection
* @return Result
*/
public function execute(Connection $databaseConnection): ResultStatement;
public function execute(Connection $databaseConnection): Result;
}
Loading

0 comments on commit dd300bc

Please sign in to comment.