Skip to content

Commit

Permalink
TASK: Harden redirectToAction
Browse files Browse the repository at this point in the history
remove logic of falling back to live workspace, but use the original workspace then instead.
  • Loading branch information
mhsdesign committed Oct 16, 2024
1 parent 8c492d9 commit 708c7c6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
Expand Down Expand Up @@ -234,20 +233,20 @@ public function redirectToAction(string $node): void
VisibilityConstraints::withoutRestrictions()
)->findNodeById($nodeAddress->aggregateId);

// we always want to redirect to the node in the base workspace.
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName($nodeAddress->workspaceName);
$workspace = $contentRepository->findWorkspaceByName($nodeAddress->workspaceName);

// we always want to redirect to the node in the base workspace.
$nodeAddressInBaseWorkspace = NodeAddress::create(
$nodeAddress->contentRepositoryId,
$workspace->baseWorkspaceName ?? WorkspaceName::forLive(),
$workspace->baseWorkspaceName ?? $nodeAddress->workspaceName,
$nodeAddress->dimensionSpacePoint,
$nodeAddress->aggregateId
);

$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest($this->request);

$this->redirectToUri(
$nodeInstance->tags->contain(SubtreeTag::disabled())
!$nodeInstance || $nodeInstance->tags->contain(SubtreeTag::disabled())
? $nodeUriBuilder->previewUriFor($nodeAddressInBaseWorkspace)
: $nodeUriBuilder->uriFor($nodeAddressInBaseWorkspace)
);
Expand Down

0 comments on commit 708c7c6

Please sign in to comment.