Skip to content

Commit

Permalink
BUGFIX: Ensure that commandMatchesAtLeastOneNode contains all comma…
Browse files Browse the repository at this point in the history
…nds for match
  • Loading branch information
mhsdesign committed Dec 11, 2024
1 parent 6bc3c55 commit fa58f0c
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Neos.ContentRepository.Core/Classes/Feature/RebaseableCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

namespace Neos\ContentRepository\Core\Feature;

use Neos\ContentRepository\Core\Feature\Common\EmbedsNodeAggregateId;
use Neos\ContentRepository\Core\Feature\Common\RebasableToOtherWorkspaceInterface;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Command\AddDimensionShineThrough;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Command\MoveDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNodeAndSerializedProperties;
use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\DisableNodeAggregate;
use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\EnableNodeAggregate;
Expand All @@ -16,6 +19,8 @@
use Neos\ContentRepository\Core\Feature\NodeRenaming\Command\ChangeNodeAggregateName;
use Neos\ContentRepository\Core\Feature\NodeTypeChange\Command\ChangeNodeAggregateType;
use Neos\ContentRepository\Core\Feature\NodeVariation\Command\CreateNodeVariant;
use Neos\ContentRepository\Core\Feature\RootNodeCreation\Command\CreateRootNodeAggregateWithNode;
use Neos\ContentRepository\Core\Feature\RootNodeCreation\Command\UpdateRootNodeAggregateDimensions;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Command\TagSubtree;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Command\UntagSubtree;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds;
Expand Down Expand Up @@ -73,16 +78,20 @@ public function separateMatchingAndRemainingCommands(

private static function commandMatchesAtLeastOneNode(
RebasableToOtherWorkspaceInterface $command,
NodeAggregateIds $nodeIdsToMatch,
NodeAggregateIds $nodeAggregateIdsToMatch,
): bool {
foreach ($nodeIdsToMatch as $nodeId) {
foreach ($nodeAggregateIdsToMatch as $nodeId) {
/**
* This match must contain all commands which are working with individual nodes, such that they are
* filterable whether they are applying their action to a NodeIdToPublish.
* filterable whether they are applying their action to a $nodeAggregateId in question
*
* This is needed to publish and discard individual nodes.
* Used to separate commands for publish and discard individual nodes
*
* NOTE: We could refactor and simplify this by asking the events {@see EmbedsNodeAggregateId}
* instead which would be more clean. But that only makes sense if we start rebasing events.
*/
$matches = match ($command::class) {
CreateRootNodeAggregateWithNode::class,
CreateNodeAggregateWithNodeAndSerializedProperties::class,
DisableNodeAggregate::class,
EnableNodeAggregate::class,
Expand All @@ -93,14 +102,17 @@ private static function commandMatchesAtLeastOneNode(
ChangeNodeAggregateType::class,
CreateNodeVariant::class,
TagSubtree::class,
UntagSubtree::class
UntagSubtree::class,
UpdateRootNodeAggregateDimensions::class,
=> $command->nodeAggregateId->equals($nodeId),
CopyNodesRecursively::class => $command->nodeAggregateIdMapping->getNewNodeAggregateId(
$command->nodeTreeToInsert->nodeAggregateId
)?->equals($nodeId),
SetSerializedNodeReferences::class => $command->sourceNodeAggregateId->equals($nodeId),
// todo return false instead to allow change to be still kept?
default => throw new \RuntimeException(sprintf('Command %s cannot be matched against a node aggregate id. Partial publish not possible.', $command::class), 1645393655)
// for non node-aggregate-changes we return false, so they are kept as remainder:
AddDimensionShineThrough::class,
MoveDimensionSpacePoint::class => false,
default => throw new \RuntimeException(sprintf('Command %s does not have matching strategy for node aggregate id (%s). Partial workspace rebase not possible.', $nodeId->value, $command::class), 1645393655)
};
if ($matches) {
return true;
Expand Down

0 comments on commit fa58f0c

Please sign in to comment.