Skip to content

Commit

Permalink
Merge branch '9.0' into task/90-doctrine-dbal-update
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsunet committed Jul 9, 2024
2 parents a7ab2cd + 78bdd81 commit d6e3b87
Show file tree
Hide file tree
Showing 176 changed files with 13,207 additions and 24,411 deletions.
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": "^3.2",
"doctrine/dbal": "^3.1.4",
"doctrine/migrations": "*"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ private function whenNodeReferencesWereSet(NodeReferencesWereSet $event, EventEn
foreach ($event->affectedSourceOriginDimensionSpacePoints as $originDimensionSpacePoint) {
$nodeAnchorPoint = $this->projectionContentGraph
->getAnchorPointForNodeAndOriginDimensionSpacePointAndContentStream(
$event->sourceNodeAggregateId,
$event->nodeAggregateId,
$originDimensionSpacePoint,
$event->contentStreamId
);
Expand Down Expand Up @@ -514,7 +514,7 @@ function (NodeRecord $node) use ($eventEnvelope) {

$nodeAnchorPoint = $this->projectionContentGraph
->getAnchorPointForNodeAndOriginDimensionSpacePointAndContentStream(
$event->sourceNodeAggregateId,
$event->nodeAggregateId,
$originDimensionSpacePoint,
$event->contentStreamId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function build(

$nodeFactory = new NodeFactory(
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
$projectionFactoryDependencies->propertyConverter,
$dimensionSpacePointsRepository
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function siblingsAreDistinctlySorted(): Result
FROM {$this->tableNames->node()}
WHERE relationanchorpoint = :relationAnchorPoint
SQL;
foreach ($ambiguouslySortedHierarchyRelationRecords->fetchAllAssociative() as $hierarchyRelationRecord) {
foreach ($ambiguouslySortedHierarchyRelationRecords->iterateAssociative() 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 @@ -26,6 +26,7 @@
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\NodeType\NodeTypeNames;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphWithRuntimeCaches\ContentSubgraphWithRuntimeCaches;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
Expand Down Expand Up @@ -132,6 +133,9 @@ public function findRootNodeAggregateByType(
foreach ($rootNodeAggregates as $rootNodeAggregate) {
$ids[] = $rootNodeAggregate->nodeAggregateId->value;
}

// We throw if multiple root node aggregates of the given $nodeTypeName were found,
// as this would lead to nondeterministic results. Must not happen.
throw new \RuntimeException(sprintf(
'More than one root node aggregate of type "%s" found (IDs: %s).',
$nodeTypeName->value,
Expand All @@ -151,12 +155,12 @@ public function findRootNodeAggregates(
FindRootNodeAggregatesFilter $filter,
): NodeAggregates {
$rootNodeAggregateQueryBuilder = $this->nodeQueryBuilder->buildFindRootNodeAggregatesQuery($this->contentStreamId, $filter);
return NodeAggregates::fromArray(iterator_to_array($this->mapQueryBuilderToNodeAggregates($rootNodeAggregateQueryBuilder)));
return $this->mapQueryBuilderToNodeAggregates($rootNodeAggregateQueryBuilder);
}

public function findNodeAggregatesByType(
NodeTypeName $nodeTypeName
): iterable {
): NodeAggregates {
$queryBuilder = $this->nodeQueryBuilder->buildBasicNodeAggregateQuery();
$queryBuilder
->andWhere('n.nodetypename = :nodeTypeName')
Expand Down Expand Up @@ -190,12 +194,10 @@ public function findNodeAggregateById(
* Parent node aggregates can have a greater dimension space coverage than the given child.
* Thus, it is not enough to just resolve them from the nodes and edges connected to the given child node aggregate.
* Instead, we resolve all parent node aggregate ids instead and fetch the complete aggregates from there.
*
* @return iterable<NodeAggregate>
*/
public function findParentNodeAggregates(
NodeAggregateId $childNodeAggregateId
): iterable {
): NodeAggregates {
$queryBuilder = $this->nodeQueryBuilder->buildBasicNodeAggregateQuery()
->innerJoin('n', $this->nodeQueryBuilder->tableNames->hierarchyRelation(), 'ch', 'ch.parentnodeanchor = n.relationanchorpoint')
->innerJoin('ch', $this->nodeQueryBuilder->tableNames->node(), 'cn', 'cn.relationanchorpoint = ch.childnodeanchor')
Expand All @@ -209,12 +211,9 @@ public function findParentNodeAggregates(
return $this->mapQueryBuilderToNodeAggregates($queryBuilder);
}

/**
* @return iterable<NodeAggregate>
*/
public function findChildNodeAggregates(
NodeAggregateId $parentNodeAggregateId
): iterable {
): NodeAggregates {
$queryBuilder = $this->nodeQueryBuilder->buildChildNodeAggregateQuery($parentNodeAggregateId, $this->contentStreamId);
return $this->mapQueryBuilderToNodeAggregates($queryBuilder);
}
Expand Down Expand Up @@ -252,7 +251,7 @@ public function findParentNodeAggregateByChildOriginDimensionSpacePoint(NodeAggr
);
}

public function findTetheredChildNodeAggregates(NodeAggregateId $parentNodeAggregateId): iterable
public function findTetheredChildNodeAggregates(NodeAggregateId $parentNodeAggregateId): NodeAggregates
{
$queryBuilder = $this->nodeQueryBuilder->buildChildNodeAggregateQuery($parentNodeAggregateId, $this->contentStreamId)
->andWhere('cn.classification = :tetheredClassification')
Expand Down Expand Up @@ -319,12 +318,12 @@ public function countNodes(): int
}
}

public function findUsedNodeTypeNames(): iterable
public function findUsedNodeTypeNames(): NodeTypeNames
{
return array_map(
return NodeTypeNames::fromArray(array_map(
static fn (array $row) => NodeTypeName::fromString($row['nodetypename']),
$this->fetchRows($this->nodeQueryBuilder->buildFindUsedNodeTypeNamesQuery())
);
));
}

private function createQueryBuilder(): QueryBuilder
Expand All @@ -346,7 +345,7 @@ private function mapQueryBuilderToNodeAggregate(QueryBuilder $queryBuilder): ?No
* @param QueryBuilder $queryBuilder
* @return \Traversable<NodeAggregate>
*/
private function mapQueryBuilderToNodeAggregates(QueryBuilder $queryBuilder): \Traversable
private function mapQueryBuilderToNodeAggregates(QueryBuilder $queryBuilder): NodeAggregates

Check failure on line 348 in Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

PHPDoc tag @return with type Traversable<mixed, Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate> is not subtype of native type Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregates.

Check failure on line 348 in Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

PHPDoc tag @return with type Traversable<mixed, Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate> is not subtype of native type Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregates.
{
return $this->nodeFactory->mapNodeRowsToNodeAggregates(
$this->fetchRows($queryBuilder),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTags;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\CoverageByOrigin;
use Neos\ContentRepository\Core\Projection\ContentGraph\DimensionSpacePointsBySubtreeTags;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregates;
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTags;
use Neos\ContentRepository\Core\Projection\ContentGraph\OriginByCoverage;
Expand Down Expand Up @@ -53,7 +53,6 @@ final class NodeFactory
{
public function __construct(
private readonly ContentRepositoryId $contentRepositoryId,
private readonly NodeTypeManager $nodeTypeManager,
private readonly PropertyConverter $propertyConverter,
private readonly DimensionSpacePointsRepository $dimensionSpacePointRepository
) {
Expand All @@ -69,10 +68,6 @@ public function mapNodeRowToNode(
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
): Node {
$nodeType = $this->nodeTypeManager->hasNodeType($nodeRow['nodetypename'])
? $this->nodeTypeManager->getNodeType($nodeRow['nodetypename'])
: null;

return Node::create(
$this->contentRepositoryId,
$workspaceName,
Expand All @@ -91,7 +86,6 @@ public function mapNodeRowToNode(
isset($nodeRow['originallastmodified']) ? self::parseDateTimeString($nodeRow['originallastmodified']) : null,
),
$visibilityConstraints,
$nodeType,
$contentStreamId
);
}
Expand Down Expand Up @@ -241,16 +235,21 @@ public function mapNodeRowsToNodeAggregate(
}

/**
* @param iterable<int,array<string,string>> $nodeRows
* @return Traversable<int,NodeAggregate>
* @param array<int,array<string,string>> $nodeRows
* @throws NodeTypeNotFound
*/
public function mapNodeRowsToNodeAggregates(
iterable $nodeRows,
array $nodeRows,
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
VisibilityConstraints $visibilityConstraints
): Traversable {
): NodeAggregates {
if (empty($nodeRows)) {
return NodeAggregates::createEmpty();
}

$nodeAggregates = [];

$nodeTypeNames = [];
$nodeNames = [];
$occupiedDimensionSpacePointsByNodeAggregate = [];
Expand Down Expand Up @@ -316,7 +315,7 @@ public function mapNodeRowsToNodeAggregates(

foreach ($nodesByOccupiedDimensionSpacePointsByNodeAggregate as $rawNodeAggregateId => $nodes) {
/** @var string $rawNodeAggregateId */
yield NodeAggregate::create(
$nodeAggregates[] = NodeAggregate::create(
$this->contentRepositoryId,
$workspaceName,
NodeAggregateId::fromString($rawNodeAggregateId),
Expand All @@ -342,6 +341,8 @@ public function mapNodeRowsToNodeAggregates(
$contentStreamId,
);
}

return NodeAggregates::fromArray($nodeAggregates);
}

public static function extractNodeTagsFromJson(string $subtreeTagsJson): NodeTags
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentGraph.PostgreSQLAdapter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "GPL-3.0+",
"require": {
"neos/contentrepository-core": "self.version",
"doctrine/dbal": "*",
"doctrine/dbal": "^3.1.4",
"doctrine/migrations": "*"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private function whenNodeReferencesWereSet(NodeReferencesWereSet $event): void
$nodeRecord = $this->getProjectionHypergraph()->findNodeRecordByOrigin(
$event->contentStreamId,
$originDimensionSpacePoint,
$event->sourceNodeAggregateId
$event->nodeAggregateId
);

if ($nodeRecord) {
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)->fetchAllAssociative() as $row) {
foreach ($this->dbal->executeQuery($query, $parameters, $types)->iterateAssociative() 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)->fetchAllAssociative() as $row) {
foreach ($this->dbal->executeQuery($query, $parameters, $types)->iterateAssociative() as $row) {
$hierarchyHyperrelations[] = HierarchyHyperrelationRecord::fromDatabaseRow($row);
}

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

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

Expand Down Expand Up @@ -316,7 +316,6 @@ public function findHierarchyHyperrelationRecordByParentNodeAnchor(
}

/**
* @throws \Doctrine\DBAL\Driver\Exception
* @throws DBALException
*/
public function findHierarchyHyperrelationRecordByChildNodeAnchor(
Expand Down Expand Up @@ -344,7 +343,6 @@ public function findHierarchyHyperrelationRecordByChildNodeAnchor(

/**
* @return array|HierarchyHyperrelationRecord[]
* @throws \Doctrine\DBAL\Driver\Exception
* @throws DBALException
*/
public function findHierarchyHyperrelationRecordsByChildNodeAnchor(
Expand All @@ -369,7 +367,6 @@ public function findHierarchyHyperrelationRecordsByChildNodeAnchor(
}

/**
* @throws \Doctrine\DBAL\Driver\Exception
* @throws DBALException
*/
public function findChildHierarchyHyperrelationRecord(
Expand Down Expand Up @@ -401,7 +398,6 @@ public function findChildHierarchyHyperrelationRecord(
* @param NodeRelationAnchorPoint $nodeRelationAnchorPoint
* @return DimensionSpacePointSet
* @throws DBALException
* @throws \Doctrine\DBAL\Driver\Exception
*/
public function findCoverageByNodeRelationAnchorPoint(
ContentStreamId $contentStreamId,
Expand Down Expand Up @@ -431,7 +427,6 @@ public function findCoverageByNodeRelationAnchorPoint(
* @param NodeAggregateId $nodeAggregateId
* @return DimensionSpacePointSet
* @throws DBALException
* @throws \Doctrine\DBAL\Driver\Exception
*/
public function findCoverageByNodeAggregateId(
ContentStreamId $contentStreamId,
Expand Down Expand Up @@ -462,7 +457,6 @@ public function findCoverageByNodeAggregateId(
* @param NodeAggregateId $originNodeAggregateId
* @return array|RestrictionHyperrelationRecord[]
* @throws DBALException
* @throws \Doctrine\DBAL\Driver\Exception
*/
public function findOutgoingRestrictionRelations(
ContentStreamId $contentStreamId,
Expand Down Expand Up @@ -499,7 +493,6 @@ public function findOutgoingRestrictionRelations(
/**
* @return array|RestrictionHyperrelationRecord[]
* @throws DBALException
* @throws \Doctrine\DBAL\Driver\Exception
*/
public function findIngoingRestrictionRelations(
ContentStreamId $contentStreamId,
Expand Down Expand Up @@ -534,7 +527,6 @@ public function findIngoingRestrictionRelations(
* @param NodeAggregateId $nodeAggregateId
* @return array|NodeAggregateIds[]
* @throws DBALException
* @throws \Doctrine\DBAL\Driver\Exception
*/
public function findDescendantNodeAggregateIds(
ContentStreamId $contentStreamId,
Expand Down
Loading

0 comments on commit d6e3b87

Please sign in to comment.