Skip to content

Commit

Permalink
Merge pull request #5270 from dlubitz/90/bugfix/cache-flush-check-if-…
Browse files Browse the repository at this point in the history
…workspace-exists

BUGFIX: Handle non-existing workspaces gracefully
  • Loading branch information
dlubitz authored Oct 1, 2024
2 parents d60a83f + a5bd579 commit f9c6812
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Event\WorkspaceWasRebased;
use Neos\ContentRepository\Core\Projection\CatchUpHookInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
Expand Down Expand Up @@ -159,7 +160,12 @@ public function onBeforeEvent(EventInterface $eventInstance, EventEnvelope $even
// cleared, leading to presumably duplicate nodes in the UI.
|| $eventInstance instanceof NodeAggregateWasMoved
) {
$contentGraph = $this->contentRepository->getContentGraph($eventInstance->workspaceName);
try {
$contentGraph = $this->contentRepository->getContentGraph($eventInstance->workspaceName);
} catch (WorkspaceDoesNotExist) {
return;
}

$nodeAggregate = $contentGraph->findNodeAggregateById(
$eventInstance->getNodeAggregateId()
);
Expand Down Expand Up @@ -197,9 +203,13 @@ public function onAfterEvent(EventInterface $eventInstance, EventEnvelope $event
&& $eventInstance instanceof EmbedsContentStreamId
&& $eventInstance instanceof EmbedsWorkspaceName
) {
$nodeAggregate = $this->contentRepository->getContentGraph($eventInstance->getWorkspaceName())->findNodeAggregateById(
$eventInstance->getNodeAggregateId()
);
try {
$nodeAggregate = $this->contentRepository->getContentGraph($eventInstance->getWorkspaceName())->findNodeAggregateById(
$eventInstance->getNodeAggregateId()
);
} catch (WorkspaceDoesNotExist) {
return;
}

if ($nodeAggregate) {
$this->scheduleCacheFlushJobForNodeAggregate(
Expand Down

0 comments on commit f9c6812

Please sign in to comment.