Skip to content

Commit

Permalink
TASK: Don't use workspaceFinder
Browse files Browse the repository at this point in the history
  • Loading branch information
dlubitz committed Oct 1, 2024
1 parent f83a7fc commit b11026d
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions Neos.Neos/Classes/AssetUsage/CatchUpHook/AssetUsageCatchUpHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\EventEnvelope;
Expand All @@ -46,13 +47,16 @@ public function onBeforeCatchUp(): void

public function onBeforeEvent(EventInterface $eventInstance, EventEnvelope $eventEnvelope): void
{
if (
$eventInstance instanceof EmbedsWorkspaceName
&& $eventInstance instanceof EmbedsContentStreamId
// Safeguard for temporary content streams created during partial publish -> We want to skip these events, because their workspace doesn't match current contentstream.
&& !$this->contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($eventInstance->getContentStreamId())?->workspaceName->equals($eventInstance->getWorkspaceName())
) {
return;
if ($eventInstance instanceof EmbedsWorkspaceName && $eventInstance instanceof EmbedsContentStreamId) {
// Safeguard for temporary content streams created during partial publish -> We want to skip these events, because their workspace doesn't match current content stream.
try {
$contentGraph = $this->contentRepository->getContentGraph($eventInstance->getWorkspaceName());
} catch (WorkspaceDoesNotExist) {
return;
}
if (!$contentGraph->getContentStreamId()->equals($eventInstance->getContentStreamId())) {
return;
}
}

match ($eventInstance::class) {
Expand All @@ -64,13 +68,16 @@ public function onBeforeEvent(EventInterface $eventInstance, EventEnvelope $even

public function onAfterEvent(EventInterface $eventInstance, EventEnvelope $eventEnvelope): void
{
if (
$eventInstance instanceof EmbedsWorkspaceName
&& $eventInstance instanceof EmbedsContentStreamId
// Safeguard for temporary content streams created during partial publish -> We want to skip these events, because their workspace doesn't match current contentstream.
&& !$this->contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($eventInstance->getContentStreamId())?->workspaceName->equals($eventInstance->getWorkspaceName())
) {
return;
if ($eventInstance instanceof EmbedsWorkspaceName && $eventInstance instanceof EmbedsContentStreamId) {
// Safeguard for temporary content streams created during partial publish -> We want to skip these events, because their workspace doesn't match current content stream.
try {
$contentGraph = $this->contentRepository->getContentGraph($eventInstance->getWorkspaceName());
} catch (WorkspaceDoesNotExist) {
return;
}
if (!$contentGraph->getContentStreamId()->equals($eventInstance->getContentStreamId())) {
return;
}
}

match ($eventInstance::class) {
Expand Down Expand Up @@ -114,7 +121,6 @@ private function removeNodes(WorkspaceName $workspaceName, NodeAggregateId $node
{
$contentGraph = $this->contentRepository->getContentGraph($workspaceName);


foreach ($dimensionSpacePoints as $dimensionSpacePoint) {
$subgraph = $contentGraph->getSubgraph($dimensionSpacePoint, VisibilityConstraints::withoutRestrictions());
$node = $subgraph->findNodeById($nodeAggregateId);
Expand Down

0 comments on commit b11026d

Please sign in to comment.