Skip to content

Commit

Permalink
BUGFIX: Asset usage prevent orphaned asset usage entries in case of a…
Browse files Browse the repository at this point in the history
… rebase with conflicts
  • Loading branch information
mhsdesign committed Dec 18, 2024
1 parent 2d44baa commit 8d5bc2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
*/
public ContentStreamId $previousContentStreamId,
/**
* Indicates if all events in the workspace were kept or if failing changes were discarded {@see RebaseErrorHandlingStrategy::STRATEGY_FORCE}
* Indicates if failing changes were discarded during a forced rebase {@see RebaseErrorHandlingStrategy::STRATEGY_FORCE} or if all events in the workspace were kept.
*/
public bool $hadConflicts
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodePeerVariantWasCreated;
use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodeSpecializationVariantWasCreated;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Event\WorkspaceWasDiscarded;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Event\WorkspaceWasRebased;
use Neos\ContentRepository\Core\Projection\CatchUpHook\CatchUpHookInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphReadModelInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter;
Expand Down Expand Up @@ -73,6 +74,12 @@ public function onAfterEvent(EventInterface $eventInstance, EventEnvelope $event
}
}

if ($eventInstance instanceof WorkspaceWasRebased && $eventInstance->hadConflicts) {
// because we don't know which changes were discarded in a conflict, we discard all changes and will build up the index on succeeding calls (with the kept reapplied events)
$this->discardWorkspace($eventInstance->getWorkspaceName());
return;
}

// Note that we don't need to update the index for WorkspaceWasPublished, as updateNode will be invoked already with the published node and then clean up its previous usages in nested workspaces
match ($eventInstance::class) {
NodeAggregateWithNodeWasCreated::class => $this->updateNode($eventInstance->getWorkspaceName(), $eventInstance->nodeAggregateId, $eventInstance->originDimensionSpacePoint->toDimensionSpacePoint()),
Expand Down

0 comments on commit 8d5bc2c

Please sign in to comment.