Skip to content

Commit

Permalink
BUGFIX: Remove initiatingUserId from node commands
Browse files Browse the repository at this point in the history
- 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@4c9dd08
Relates: #3349
  • Loading branch information
ahaeslich committed Jan 31, 2023
1 parent 5e9c6d9 commit 5d69c44
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 49 deletions.
8 changes: 0 additions & 8 deletions Classes/Domain/Model/AbstractChange.php
Expand Up @@ -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));
}
}
9 changes: 4 additions & 5 deletions Classes/Domain/Model/Changes/AbstractCreate.php
Expand Up @@ -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;

Expand Down
8 changes: 2 additions & 6 deletions Classes/Domain/Model/Changes/CopyAfter.php
Expand Up @@ -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
{
Expand Down Expand Up @@ -77,7 +74,6 @@ public function apply(): void
),
$subject,
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
$this->getInitiatingUserIdentifier(),
$parentNodeOfPreviousSibling->nodeAggregateId,
$succeedingSibling?->nodeAggregateId,
$targetNodeName
Expand Down
3 changes: 1 addition & 2 deletions Classes/Domain/Model/Changes/MoveAfter.php
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions Classes/Domain/Model/Changes/MoveBefore.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions Classes/Domain/Model/Changes/MoveInto.php
Expand Up @@ -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();

Expand Down
34 changes: 13 additions & 21 deletions Classes/Domain/Model/Changes/Property.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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 {
Expand All @@ -199,8 +196,7 @@ public function apply(): void
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint,
$originDimensionSpacePoint,
$this->getInitiatingUserIdentifier()
$originDimensionSpacePoint
)
)->block();
}
Expand All @@ -213,8 +209,7 @@ public function apply(): void
[
$propertyName => $value
]
),
$this->getInitiatingUserIdentifier()
)
)
);
} else {
Expand All @@ -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') {
Expand All @@ -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 {
Expand All @@ -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
)
);
}
Expand Down
3 changes: 1 addition & 2 deletions Classes/Domain/Model/Changes/Remove.php
Expand Up @@ -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();

Expand All @@ -74,7 +74,6 @@ public function apply(): void
$subject->nodeAggregateId,
$subject->subgraphIdentity->dimensionSpacePoint,
NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS,
$this->getInitiatingUserIdentifier(),
$closestDocumentParentNode?->nodeAggregateId
);

Expand Down

0 comments on commit 5d69c44

Please sign in to comment.