From 5d69c44b337b77ed344bc100f605a13722e6ecb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anke=20H=C3=A4slich?= Date: Tue, 31 Jan 2023 21:45:27 +0100 Subject: [PATCH] BUGFIX: Remove initiatingUserId from node commands - checked for all usages of `getInitiatingUserIdentifier` to remove the initiatingUserId from node commands - removed function `getInitiatingUserIdentifier` because it is not needed anymore - removed unused imported classes in touched files Relates: neos/neos-development-collection@4c9dd087324317c8b2823b2ee4a658b23d638892 Relates: #3349 --- Classes/Domain/Model/AbstractChange.php | 8 ----- .../Domain/Model/Changes/AbstractCreate.php | 9 +++-- Classes/Domain/Model/Changes/CopyAfter.php | 8 ++--- Classes/Domain/Model/Changes/MoveAfter.php | 3 +- Classes/Domain/Model/Changes/MoveBefore.php | 4 +-- Classes/Domain/Model/Changes/MoveInto.php | 3 +- Classes/Domain/Model/Changes/Property.php | 34 +++++++------------ Classes/Domain/Model/Changes/Remove.php | 3 +- 8 files changed, 23 insertions(+), 49 deletions(-) diff --git a/Classes/Domain/Model/AbstractChange.php b/Classes/Domain/Model/AbstractChange.php index 15efcf30bc..ab6a55c4e6 100644 --- a/Classes/Domain/Model/AbstractChange.php +++ b/Classes/Domain/Model/AbstractChange.php @@ -125,12 +125,4 @@ protected function addNodeCreatedFeedback(Node $subject = null): void $this->feedbackCollection->add($nodeCreated); } } - - final protected function getInitiatingUserIdentifier(): UserId - { - /** @var User $user */ - $user = $this->userService->getBackendUser(); - - return UserId::fromString($this->persistenceManager->getIdentifierByObject($user)); - } } diff --git a/Classes/Domain/Model/Changes/AbstractCreate.php b/Classes/Domain/Model/Changes/AbstractCreate.php index 6b1b326c42..d2d8199005 100644 --- a/Classes/Domain/Model/Changes/AbstractCreate.php +++ b/Classes/Domain/Model/Changes/AbstractCreate.php @@ -13,14 +13,13 @@ */ use Neos\ContentRepository\Core\ContentRepository; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; +use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNode; +use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepository\Core\SharedModel\Exception\NodeNameIsAlreadyOccupied; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Node\NodeName; -use Neos\ContentRepository\Core\NodeType\NodeTypeName; -use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNode; -use Neos\ContentRepository\Core\SharedModel\Exception\NodeNameIsAlreadyOccupied; -use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Neos\Ui\Exception\InvalidNodeCreationHandlerException; use Neos\Neos\Ui\NodeCreationHandler\NodeCreationHandlerInterface; diff --git a/Classes/Domain/Model/Changes/CopyAfter.php b/Classes/Domain/Model/Changes/CopyAfter.php index a8d71c1052..e4725f05a5 100644 --- a/Classes/Domain/Model/Changes/CopyAfter.php +++ b/Classes/Domain/Model/Changes/CopyAfter.php @@ -12,13 +12,10 @@ * source code. */ -use Neos\ContentRepository\Core\SharedModel\Node\NodeName; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; -use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; -use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\Flow\Annotations as Flow; use Neos\ContentRepository\Core\Feature\NodeDuplication\Command\CopyNodesRecursively; -use Neos\ContentRepository\Core\Feature\NodeDuplication\NodeDuplicationCommandHandler; +use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; +use Neos\ContentRepository\Core\SharedModel\Node\NodeName; class CopyAfter extends AbstractStructuralChange { @@ -77,7 +74,6 @@ public function apply(): void ), $subject, OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint), - $this->getInitiatingUserIdentifier(), $parentNodeOfPreviousSibling->nodeAggregateId, $succeedingSibling?->nodeAggregateId, $targetNodeName diff --git a/Classes/Domain/Model/Changes/MoveAfter.php b/Classes/Domain/Model/Changes/MoveAfter.php index 0936208c78..99df888cfc 100644 --- a/Classes/Domain/Model/Changes/MoveAfter.php +++ b/Classes/Domain/Model/Changes/MoveAfter.php @@ -78,8 +78,7 @@ public function apply(): void $hasEqualParentNode ? null : $parentNodeOfPreviousSibling->nodeAggregateId, $precedingSibling->nodeAggregateId, $succeedingSibling?->nodeAggregateId, - RelationDistributionStrategy::STRATEGY_GATHER_ALL, - $this->getInitiatingUserIdentifier() + RelationDistributionStrategy::STRATEGY_GATHER_ALL ); $contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId); diff --git a/Classes/Domain/Model/Changes/MoveBefore.php b/Classes/Domain/Model/Changes/MoveBefore.php index 4a9e71bcb6..27d1078c07 100644 --- a/Classes/Domain/Model/Changes/MoveBefore.php +++ b/Classes/Domain/Model/Changes/MoveBefore.php @@ -12,7 +12,6 @@ * source code. */ -use Neos\ContentRepository\Core\Feature\NodeAggregateCommandHandler; use Neos\ContentRepository\Core\Feature\NodeMove\Command\MoveNodeAggregate; use Neos\ContentRepository\Core\Feature\NodeMove\Dto\RelationDistributionStrategy; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode; @@ -79,8 +78,7 @@ public function apply(): void : $succeedingSiblingParent->nodeAggregateId, $precedingSibling?->nodeAggregateId, $succeedingSibling->nodeAggregateId, - RelationDistributionStrategy::STRATEGY_GATHER_ALL, - $this->getInitiatingUserIdentifier() + RelationDistributionStrategy::STRATEGY_GATHER_ALL ) )->block(); diff --git a/Classes/Domain/Model/Changes/MoveInto.php b/Classes/Domain/Model/Changes/MoveInto.php index 43bad83b2d..4ca90a9b54 100644 --- a/Classes/Domain/Model/Changes/MoveInto.php +++ b/Classes/Domain/Model/Changes/MoveInto.php @@ -87,8 +87,7 @@ public function apply(): void $hasEqualParentNode ? null : $parentNode->nodeAggregateId, null, null, - RelationDistributionStrategy::STRATEGY_GATHER_ALL, - $this->getInitiatingUserIdentifier() + RelationDistributionStrategy::STRATEGY_GATHER_ALL ) )->block(); diff --git a/Classes/Domain/Model/Changes/Property.php b/Classes/Domain/Model/Changes/Property.php index da02947b78..43017d45ba 100644 --- a/Classes/Domain/Model/Changes/Property.php +++ b/Classes/Domain/Model/Changes/Property.php @@ -13,23 +13,22 @@ */ use Neos\ContentRepository\Core\DimensionSpace\Exception\DimensionSpacePointNotFound; -use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet; -use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregatesTypeIsAmbiguous; -use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\NodeReferencesToWrite; -use Neos\ContentRepository\Core\SharedModel\Node\NodeVariantSelectionStrategy; -use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\DisableNodeAggregate; use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\EnableNodeAggregate; use Neos\ContentRepository\Core\Feature\NodeModification\Command\SetNodeProperties; +use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite; use Neos\ContentRepository\Core\Feature\NodeReferencing\Command\SetNodeReferences; +use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\NodeReferencesToWrite; use Neos\ContentRepository\Core\Feature\NodeTypeChange\Command\ChangeNodeAggregateType; use Neos\ContentRepository\Core\Feature\NodeTypeChange\Dto\NodeAggregateTypeChangeChildConstraintConflictResolutionStrategy; use Neos\ContentRepository\Core\Feature\NodeVariation\Command\CreateNodeVariant; +use Neos\ContentRepository\Core\NodeType\NodeTypeName; +use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet; +use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregatesTypeIsAmbiguous; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds; -use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; -use Neos\ContentRepository\Core\SharedModel\Node\PropertyName; +use Neos\ContentRepository\Core\SharedModel\Node\NodeVariantSelectionStrategy; use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName; -use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\Flow\Annotations as Flow; use Neos\Neos\Ui\Domain\Model\AbstractChange; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadContentOutOfBand; @@ -149,7 +148,6 @@ public function apply(): void $contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId); $propertyType = $subject->nodeType->getPropertyType($propertyName); - $userIdentifier = $this->getInitiatingUserIdentifier(); // Use extra commands for reference handling if ($propertyType === 'reference' || $propertyType === 'references') { @@ -177,8 +175,7 @@ public function apply(): void $subject->nodeAggregateId, $subject->originDimensionSpacePoint, ReferenceName::fromString($propertyName), - NodeReferencesToWrite::fromNodeAggregateIds(NodeAggregateIds::fromArray($destinationNodeAggregateIdentifiers)), - $this->getInitiatingUserIdentifier() + NodeReferencesToWrite::fromNodeAggregateIds(NodeAggregateIds::fromArray($destinationNodeAggregateIdentifiers)) ) ); } else { @@ -199,8 +196,7 @@ public function apply(): void $subject->subgraphIdentity->contentStreamId, $subject->nodeAggregateId, $subject->originDimensionSpacePoint, - $originDimensionSpacePoint, - $this->getInitiatingUserIdentifier() + $originDimensionSpacePoint ) )->block(); } @@ -213,8 +209,7 @@ public function apply(): void [ $propertyName => $value ] - ), - $this->getInitiatingUserIdentifier() + ) ) ); } else { @@ -225,8 +220,7 @@ public function apply(): void $subject->subgraphIdentity->contentStreamId, $subject->nodeAggregateId, NodeTypeName::fromString($value), - NodeAggregateTypeChangeChildConstraintConflictResolutionStrategy::STRATEGY_DELETE, - $userIdentifier + NodeAggregateTypeChangeChildConstraintConflictResolutionStrategy::STRATEGY_DELETE ) ); } elseif ($propertyName === '_hidden') { @@ -236,8 +230,7 @@ public function apply(): void $subject->subgraphIdentity->contentStreamId, $subject->nodeAggregateId, $subject->originDimensionSpacePoint->toDimensionSpacePoint(), - NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS, - $userIdentifier + NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS ) ); } else { @@ -247,8 +240,7 @@ public function apply(): void $subject->subgraphIdentity->contentStreamId, $subject->nodeAggregateId, $subject->originDimensionSpacePoint->toDimensionSpacePoint(), - NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS, - $userIdentifier + NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS ) ); } diff --git a/Classes/Domain/Model/Changes/Remove.php b/Classes/Domain/Model/Changes/Remove.php index 51520efa79..6f6d9dc4db 100644 --- a/Classes/Domain/Model/Changes/Remove.php +++ b/Classes/Domain/Model/Changes/Remove.php @@ -64,7 +64,7 @@ public function apply(): void ); } - // we have to schedule an the update workspace info before we actually delete the node; + // we have to schedule and the update workspace info before we actually delete the node; // otherwise we cannot find the parent nodes anymore. $this->updateWorkspaceInfo(); @@ -74,7 +74,6 @@ public function apply(): void $subject->nodeAggregateId, $subject->subgraphIdentity->dimensionSpacePoint, NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS, - $this->getInitiatingUserIdentifier(), $closestDocumentParentNode?->nodeAggregateId );