From fc500360e4e3b170c96303134375c8ef6e4a17b2 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Thu, 24 Oct 2024 15:03:29 +0200 Subject: [PATCH 1/3] TASK: Show changes to nodeAggregates for occupied nodes dimensionspacepoints --- .../Service/WorkspaceService.php | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/Classes/ContentRepository/Service/WorkspaceService.php b/Classes/ContentRepository/Service/WorkspaceService.php index 43cb89155f..b880763061 100644 --- a/Classes/ContentRepository/Service/WorkspaceService.php +++ b/Classes/ContentRepository/Service/WorkspaceService.php @@ -1,4 +1,5 @@ removalAttachmentPoint) { + if ($change->removalAttachmentPoint && $change->originDimensionSpacePoint !== null) { $nodeAddress = NodeAddress::create( $contentRepositoryId, $workspaceName, @@ -79,20 +80,32 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo 'typeOfChange' => $this->getTypeOfChange($change) ]; } else { - $subgraph = $contentRepository->getContentGraph($workspaceName)->getSubgraph( - $change->originDimensionSpacePoint->toDimensionSpacePoint(), - VisibilityConstraints::withoutRestrictions() - ); - $node = $subgraph->findNodeById($change->nodeAggregateId); - - if ($node instanceof Node) { - $documentNode = $subgraph->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT)); - if ($documentNode instanceof Node) { - $unpublishedNodes[] = [ - 'contextPath' => NodeAddress::fromNode($node)->toJson(), - 'documentContextPath' => NodeAddress::fromNode($documentNode)->toJson(), - 'typeOfChange' => $this->getTypeOfChange($change) - ]; + if ($change->originDimensionSpacePoint !== null) { + $originDimensionSpacePoints = [$change->originDimensionSpacePoint]; + } else { + // If originDimensionSpacePoint is null, we have a change to the nodeAggregate. All nodes in the + // occupied dimensionspacepoints shall be marked as changed. + $originDimensionSpacePoints = $contentRepository + ->getContentGraph($workspaceName) + ->findNodeAggregateById($change->nodeAggregateId) + ?->occupiedDimensionSpacePoints ?: []; + } + + foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) { + $subgraph = $contentRepository->getContentGraph($workspaceName)->getSubgraph( + $originDimensionSpacePoint->toDimensionSpacePoint(), + VisibilityConstraints::withoutRestrictions() + ); + $node = $subgraph->findNodeById($change->nodeAggregateId); + if ($node instanceof Node) { + $documentNode = $subgraph->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT)); + if ($documentNode instanceof Node) { + $unpublishedNodes[] = [ + 'contextPath' => NodeAddress::fromNode($node)->toJson(), + 'documentContextPath' => NodeAddress::fromNode($documentNode)->toJson(), + 'typeOfChange' => $this->getTypeOfChange($change) + ]; + } } } } From bbf744c1073f4f3a7e67125d1b9eeb08a48843cd Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Thu, 24 Oct 2024 15:22:33 +0200 Subject: [PATCH 2/3] TASK: Load contentGraph once --- Classes/ContentRepository/Service/WorkspaceService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/ContentRepository/Service/WorkspaceService.php b/Classes/ContentRepository/Service/WorkspaceService.php index b880763061..9f43d9e717 100644 --- a/Classes/ContentRepository/Service/WorkspaceService.php +++ b/Classes/ContentRepository/Service/WorkspaceService.php @@ -52,6 +52,7 @@ class WorkspaceService public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepositoryId $contentRepositoryId): array { $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); + $contentGraph = $contentRepository->getContentGraph($workspaceName); $pendingChanges = $this->workspacePublishingService->pendingWorkspaceChanges($contentRepositoryId, $workspaceName); /** @var array{contextPath:string,documentContextPath:string,typeOfChange:int}[] $unpublishedNodes */ $unpublishedNodes = []; @@ -92,7 +93,7 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo } foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) { - $subgraph = $contentRepository->getContentGraph($workspaceName)->getSubgraph( + $subgraph = $contentGraph->getSubgraph( $originDimensionSpacePoint->toDimensionSpacePoint(), VisibilityConstraints::withoutRestrictions() ); From b3bafccea646a1fb2227e5563c09a6b50fae3f4f Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Thu, 24 Oct 2024 15:23:20 +0200 Subject: [PATCH 3/3] TASK: Load contentGraph once --- Classes/ContentRepository/Service/WorkspaceService.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Classes/ContentRepository/Service/WorkspaceService.php b/Classes/ContentRepository/Service/WorkspaceService.php index 9f43d9e717..d1b9834a3c 100644 --- a/Classes/ContentRepository/Service/WorkspaceService.php +++ b/Classes/ContentRepository/Service/WorkspaceService.php @@ -86,8 +86,7 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo } else { // If originDimensionSpacePoint is null, we have a change to the nodeAggregate. All nodes in the // occupied dimensionspacepoints shall be marked as changed. - $originDimensionSpacePoints = $contentRepository - ->getContentGraph($workspaceName) + $originDimensionSpacePoints = $contentGraph ->findNodeAggregateById($change->nodeAggregateId) ?->occupiedDimensionSpacePoints ?: []; }