Skip to content

Commit fe52b16

Browse files
BUGFIX: Fix hidden state evaluation (#3867)
* 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 <b.waidelich@wwwision.de> --------- Co-authored-by: Bastian Waidelich <b.waidelich@wwwision.de>
1 parent e394d8d commit fe52b16

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

Classes/Controller/BackendController.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* source code.
1313
*/
1414

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

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

229+
$contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId);
230+
231+
$nodeInstance = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
232+
$nodeAddress->dimensionSpacePoint,
233+
VisibilityConstraints::withoutRestrictions()
234+
)->findNodeById($nodeAddress->aggregateId);
235+
236+
$workspace = $contentRepository->findWorkspaceByName($nodeAddress->workspaceName);
237+
238+
// 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)
239+
$nodeAddressInBaseWorkspace = NodeAddress::create(
240+
$nodeAddress->contentRepositoryId,
241+
$workspace->baseWorkspaceName ?? $nodeAddress->workspaceName,
242+
$nodeAddress->dimensionSpacePoint,
243+
$nodeAddress->aggregateId
244+
);
245+
246+
$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest($this->request);
247+
228248
$this->redirectToUri(
229-
$this->nodeUriBuilderFactory->forActionRequest($this->request)
230-
->uriFor($nodeAddress)
249+
!$nodeInstance || $nodeInstance->tags->contain(SubtreeTag::disabled())
250+
? $nodeUriBuilder->previewUriFor($nodeAddressInBaseWorkspace)
251+
: $nodeUriBuilder->uriFor($nodeAddressInBaseWorkspace)
231252
);
232253
}
233254
}

Classes/Fusion/Helper/NodeInfoHelper.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
1818
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
1919
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
20-
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
2120
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
2221
use Neos\Eel\ProtectedContextAwareInterface;
2322
use Neos\Flow\Annotations as Flow;
@@ -351,16 +350,7 @@ public function previewUri(Node $node, ActionRequest $actionRequest): string
351350

352351
public function createRedirectToNode(Node $node, ActionRequest $actionRequest): string
353352
{
354-
// we always want to redirect to the node in the base workspace.
355-
$contentRepository = $this->contentRepositoryRegistry->get($node->contentRepositoryId);
356-
$workspace = $contentRepository->findWorkspaceByName($node->workspaceName);
357-
358-
$nodeAddress = NodeAddress::create(
359-
$node->contentRepositoryId,
360-
$workspace->baseWorkspaceName ?? WorkspaceName::forLive(),
361-
$node->dimensionSpacePoint,
362-
$node->aggregateId
363-
);
353+
$nodeAddress = NodeAddress::fromNode($node);
364354

365355
$uriBuilder = new UriBuilder();
366356
$uriBuilder->setRequest($actionRequest);

0 commit comments

Comments
 (0)