From b11026d6bed5dee1cbfb514dfea3a90039b47100 Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Tue, 1 Oct 2024 15:52:44 +0200 Subject: [PATCH] TASK: Don't use workspaceFinder --- .../CatchUpHook/AssetUsageCatchUpHook.php | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Neos.Neos/Classes/AssetUsage/CatchUpHook/AssetUsageCatchUpHook.php b/Neos.Neos/Classes/AssetUsage/CatchUpHook/AssetUsageCatchUpHook.php index 09f42ba99d6..e240adb41bc 100644 --- a/Neos.Neos/Classes/AssetUsage/CatchUpHook/AssetUsageCatchUpHook.php +++ b/Neos.Neos/Classes/AssetUsage/CatchUpHook/AssetUsageCatchUpHook.php @@ -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; @@ -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) { @@ -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) { @@ -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);