Skip to content

Commit

Permalink
BUGFIX: Graceful site detection and early return
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Feb 16, 2024
1 parent 9161acc commit a2dd063
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use Neos\Neos\FrontendRouting\DimensionResolution\DelegatingResolver;
use Neos\Neos\FrontendRouting\DimensionResolution\RequestToDimensionSpacePointContext;
use Neos\Neos\FrontendRouting\DimensionResolution\DimensionResolverInterface;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionFailedException;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionMiddleware;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Psr\Http\Message\UriInterface;
Expand Down Expand Up @@ -175,7 +176,11 @@ public function matchWithParameters(&$requestPath, RouteParameters $parameters)
return false;
}

$siteDetectionResult = SiteDetectionResult::fromRouteParameters($parameters);
try {
$siteDetectionResult = SiteDetectionResult::fromRouteParameters($parameters);
} catch (SiteDetectionFailedException) {
return false;
}
$resolvedSite = $this->siteRepository->findOneByNodeName($siteDetectionResult->siteNodeName);

if ($resolvedSite === null) {
Expand All @@ -196,7 +201,6 @@ public function matchWithParameters(&$requestPath, RouteParameters $parameters)
// TODO validate dsp == complete (ContentDimensionZookeeper::getAllowedDimensionSubspace()->contains()...)
// if incomplete -> no match + log

$siteDetectionResult = SiteDetectionResult::fromRouteParameters($parameters);
$contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId);

try {
Expand Down
11 changes: 9 additions & 2 deletions Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use Neos\Flow\Security\Policy\Role;
use Neos\Neos\Domain\Model\User;
use Neos\Neos\Domain\Service\WorkspaceNameBuilder;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionFailedException;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Neos\Party\Domain\Service\PartyService;

Expand Down Expand Up @@ -95,7 +96,11 @@ public function relayEditorAuthentication(Authentication\TokenInterface $token):
// we might be in testing context
return;
}
$siteDetectionResult = SiteDetectionResult::fromRequest($requestHandler->getHttpRequest());
try {
$siteDetectionResult = SiteDetectionResult::fromRequest($requestHandler->getHttpRequest());
} catch (SiteDetectionFailedException) {
return;
}
$contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId);

$isEditor = false;
Expand Down Expand Up @@ -131,8 +136,10 @@ public function relayEditorAuthentication(Authentication\TokenInterface $token):
return;
}

/** @var Workspace $baseWorkspace */
$baseWorkspace = $contentRepository->getWorkspaceFinder()->findOneByName(WorkspaceName::forLive());
if (!$baseWorkspace) {
return;
}
$editorsNewContentStreamId = ContentStreamId::create();
$contentRepository->handle(
CreateWorkspace::create(
Expand Down

0 comments on commit a2dd063

Please sign in to comment.