From 577a067cb27885522f619b62bb6c5c0004fa8852 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 14 Feb 2025 09:55:10 +0100 Subject: [PATCH] TASK: Adjust to removed `removalAttachmentPoint` neos: 316bf261a9448a612b0d6644eeb4de951763730f --- .../Service/WorkspaceService.php | 69 ++++++------------- Classes/Domain/Model/Changes/Remove.php | 2 + 2 files changed, 23 insertions(+), 48 deletions(-) diff --git a/Classes/ContentRepository/Service/WorkspaceService.php b/Classes/ContentRepository/Service/WorkspaceService.php index d212235bec..42abb12d14 100644 --- a/Classes/ContentRepository/Service/WorkspaceService.php +++ b/Classes/ContentRepository/Service/WorkspaceService.php @@ -57,61 +57,34 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo /** @var array{contextPath:string,documentContextPath:string,typeOfChange:int}[] $unpublishedNodes */ $unpublishedNodes = []; foreach ($pendingChanges as $change) { - if ($change->removalAttachmentPoint && $change->originDimensionSpacePoint !== null) { - $nodeAddress = NodeAddress::create( - $contentRepositoryId, - $workspaceName, - $change->originDimensionSpacePoint->toDimensionSpacePoint(), - $change->nodeAggregateId - ); - - /** - * See {@see Remove::apply} -> Removal Attachment Point == closest document node. - */ - $documentNodeAddress = NodeAddress::create( - $contentRepositoryId, - $workspaceName, - $change->originDimensionSpacePoint->toDimensionSpacePoint(), - $change->removalAttachmentPoint - ); - - $unpublishedNodes[] = [ - 'contextPath' => $nodeAddress->toJson(), - 'documentContextPath' => $documentNodeAddress->toJson(), - 'typeOfChange' => $this->getTypeOfChange($change) - ]; + if ($change->originDimensionSpacePoint !== null) { + $originDimensionSpacePoints = [$change->originDimensionSpacePoint]; } else { - 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 = $contentGraph - ->findNodeAggregateById($change->nodeAggregateId) - ?->occupiedDimensionSpacePoints ?: []; - } + // If originDimensionSpacePoint is null, we have a change to the nodeAggregate. All nodes in the + // occupied dimensionspacepoints shall be marked as changed. + $originDimensionSpacePoints = $contentGraph + ->findNodeAggregateById($change->nodeAggregateId) + ?->occupiedDimensionSpacePoints ?: []; + } - $contentGraph = $contentRepository->getContentGraph($workspaceName); - foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) { - $subgraph = $contentGraph->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) - ]; - } + $contentGraph = $contentRepository->getContentGraph($workspaceName); + foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) { + $subgraph = $contentGraph->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) + ]; } } } } - return array_values(array_filter($unpublishedNodes, function ($item) { - return (bool)$item; - })); + return $unpublishedNodes; } private function getTypeOfChange(Change $change): int diff --git a/Classes/Domain/Model/Changes/Remove.php b/Classes/Domain/Model/Changes/Remove.php index d3f1be5adf..d7019b33e2 100644 --- a/Classes/Domain/Model/Changes/Remove.php +++ b/Classes/Domain/Model/Changes/Remove.php @@ -63,6 +63,8 @@ public function apply(): void // otherwise we cannot find the parent nodes anymore. $this->updateWorkspaceInfo(); + // Issuing 'real' deletions via 'RemoveNodeAggregate' on a non-live workspace are not desired in Neos + // as these changes are not correctly publishable via the neos ui. Instead, we must use tagging to soft-delete nodes. $command = TagSubtree::create( $subject->workspaceName, $subject->aggregateId,