Skip to content

Commit

Permalink
BUGFIX: Fix hidden state evaluation (#3867)
Browse files Browse the repository at this point in the history
* TASK: Fix hidden state evaluation

The Neos 8.3 LinkingService contained this logic
```
$action = $node->getContext()->getWorkspace()->isPublicWorkspace() && !$node->isHidden() ? 'show' : 'preview';
```
ensuring that disabled nodes can still be previewed.
In Neos 9 a no route matched error will be thrown.

To restore the old behaviour we evaluate the hidden state

* TASK: Harden `redirectToAction`

remove logic of falling back to live workspace, but use the original workspace then instead.

* update comment

Co-authored-by: Bastian Waidelich <[email protected]>

---------

Co-authored-by: Bastian Waidelich <[email protected]>
  • Loading branch information
mhsdesign and bwaidelich authored Oct 16, 2024
1 parent e394d8d commit fe52b16
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
25 changes: 23 additions & 2 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* source code.
*/

use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
Expand Down Expand Up @@ -225,9 +226,29 @@ public function redirectToAction(string $node): void

$nodeAddress = NodeAddress::fromJsonString($node);

$contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId);

$nodeInstance = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
$nodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
)->findNodeById($nodeAddress->aggregateId);

$workspace = $contentRepository->findWorkspaceByName($nodeAddress->workspaceName);

// we always want to redirect to the node in the base workspace unless we are on a root workspace in which case we stay on that (currently that will not happen)
$nodeAddressInBaseWorkspace = NodeAddress::create(
$nodeAddress->contentRepositoryId,
$workspace->baseWorkspaceName ?? $nodeAddress->workspaceName,
$nodeAddress->dimensionSpacePoint,
$nodeAddress->aggregateId
);

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

$this->redirectToUri(
$this->nodeUriBuilderFactory->forActionRequest($this->request)
->uriFor($nodeAddress)
!$nodeInstance || $nodeInstance->tags->contain(SubtreeTag::disabled())
? $nodeUriBuilder->previewUriFor($nodeAddressInBaseWorkspace)
: $nodeUriBuilder->uriFor($nodeAddressInBaseWorkspace)
);
}
}
12 changes: 1 addition & 11 deletions Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Eel\ProtectedContextAwareInterface;
use Neos\Flow\Annotations as Flow;
Expand Down Expand Up @@ -351,16 +350,7 @@ public function previewUri(Node $node, ActionRequest $actionRequest): string

public function createRedirectToNode(Node $node, ActionRequest $actionRequest): string
{
// we always want to redirect to the node in the base workspace.
$contentRepository = $this->contentRepositoryRegistry->get($node->contentRepositoryId);
$workspace = $contentRepository->findWorkspaceByName($node->workspaceName);

$nodeAddress = NodeAddress::create(
$node->contentRepositoryId,
$workspace->baseWorkspaceName ?? WorkspaceName::forLive(),
$node->dimensionSpacePoint,
$node->aggregateId
);
$nodeAddress = NodeAddress::fromNode($node);

$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($actionRequest);
Expand Down

0 comments on commit fe52b16

Please sign in to comment.