From ba59c62d9557addbdb7121cddd80d3c2112ee2b5 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:17:55 +0100 Subject: [PATCH 01/15] TASK: Improve error message if node address from router is stale The router cache is still used in combination with our routing projection. That could possibly lead to this error when our cache flushing cant keep up, like when deleting tables :D > TODO: SITE NOT FOUND; should not happen (for address NodeAddress[...] This changes the error to point to a possible cause, the Flow_Mvc_Routing_Route Ideally our `RouterCacheHook` should always keep up. --- .../Classes/Controller/Frontend/NodeController.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Neos.Neos/Classes/Controller/Frontend/NodeController.php b/Neos.Neos/Classes/Controller/Frontend/NodeController.php index f5ae466fd07..4bc115447ee 100644 --- a/Neos.Neos/Classes/Controller/Frontend/NodeController.php +++ b/Neos.Neos/Classes/Controller/Frontend/NodeController.php @@ -207,19 +207,18 @@ public function showAction(string $node): void VisibilityConstraints::frontend() ); + $nodeInstance = $subgraph->findNodeById($nodeAddress->nodeAggregateId); + if ($nodeInstance === null) { + throw new NodeNotFoundException(sprintf('The cached node address for this uri could not be resolved. Possibly you have to flush the "Flow_Mvc_Routing_Route" cache. %s', $nodeAddress), 1707300738); + } + $site = $subgraph->findClosestNode($nodeAddress->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE)); if ($site === null) { - throw new NodeNotFoundException("TODO: SITE NOT FOUND; should not happen (for address " . $nodeAddress); + throw new NodeNotFoundException(sprintf('The site node of %s could not be resolved.', $nodeAddress), 1707300861); } $this->fillCacheWithContentNodes($nodeAddress->nodeAggregateId, $subgraph); - $nodeInstance = $subgraph->findNodeById($nodeAddress->nodeAggregateId); - - if ($nodeInstance === null) { - throw new NodeNotFoundException('The requested node does not exist', 1596191460); - } - if ($this->getNodeType($nodeInstance)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT)) { $this->handleShortcutNode($nodeAddress, $contentRepository); } From d8d36efbf1588b8553ac429b13e62cbfaf8843b3 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:36:47 +0100 Subject: [PATCH 02/15] TASK: Improve error message if site entity exists but no cr --- .../FrontendRouting/Projection/DocumentUriPathFinder.php | 6 +++--- .../SiteDetection/SiteDetectionMiddleware.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathFinder.php b/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathFinder.php index b0ade4bd6e9..413d2dac480 100644 --- a/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathFinder.php +++ b/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathFinder.php @@ -242,7 +242,7 @@ private function fetchSingle(string $where, array $parameters): DocumentNodeInfo ); } catch (DBALException $e) { throw new \RuntimeException(sprintf( - 'Failed to load node for query "%s": %s', + 'Failed to fetch a node, please ensure the projection is setup. Query "%s". %s', $where, $e->getMessage() ), 1599664746, $e); @@ -273,7 +273,7 @@ private function fetchMultiple(string $where, array $parameters): DocumentNodeIn ); } catch (DBALException $e) { throw new \RuntimeException(sprintf( - 'Failed to load node for query "%s": %s', + 'Failed to fetch multiple nodes, please ensure the projection is setup. Query "%s". %s', $where, $e->getMessage() ), 1683808640, $e); @@ -314,7 +314,7 @@ public function disableCache(): void public function getDescendantsOfNode(DocumentNodeInfo $node): DocumentNodeInfos { return $this->fetchMultiple( - 'dimensionSpacePointHash = :dimensionSpacePointHash + 'dimensionSpacePointHash = :dimensionSpacePointHash AND nodeAggregateIdPath LIKE :childNodeAggregateIdPathPrefix', [ 'dimensionSpacePointHash' => $node->getDimensionSpacePointHash(), diff --git a/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionMiddleware.php b/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionMiddleware.php index 9f1003588d6..7728c3b5361 100644 --- a/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionMiddleware.php +++ b/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionMiddleware.php @@ -65,6 +65,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface return $handler->handle($request); } + // doctrine is running and we could fetch a site. This makes no promise if the content repository is set up. $siteDetectionResult = SiteDetectionResult::create($site->getNodeName(), $site->getConfiguration()->contentRepositoryId); return $handler->handle($siteDetectionResult->storeInRequest($request)); } From cf983a94584aaaea9f81771eae7274879097ce73 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:44:09 +0100 Subject: [PATCH 03/15] TASK: Improve error message if the site entity is to be removed but the cr is not setup --- Neos.Neos/Classes/Domain/Service/SiteService.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Neos.Neos/Classes/Domain/Service/SiteService.php b/Neos.Neos/Classes/Domain/Service/SiteService.php index c50a5a6f86b..0fe7b730fd0 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteService.php +++ b/Neos.Neos/Classes/Domain/Service/SiteService.php @@ -73,7 +73,15 @@ public function pruneSite(Site $site): void $site->getConfiguration()->contentRepositoryId, new SiteServiceInternalsFactory() ); - $siteServiceInternals->removeSiteNode($site->getNodeName()); + + try { + $siteServiceInternals->removeSiteNode($site->getNodeName()); + } catch (\Doctrine\DBAL\Exception $exception) { + throw new \RuntimeException(sprintf( + 'Could not remove site nodes for site "%s", please ensure the content repository is setup.', + $site->getName() + ), 1707302419, $exception); + } $site->setPrimaryDomain(null); $this->siteRepository->update($site); From 3b3ceb9c8cf75b424d3aca798f145913642def4e Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:58:57 +0100 Subject: [PATCH 04/15] TASK: Remove unused `NoHomepageException` --- .../Routing/Exception/NoHomepageException.php | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 Neos.Neos/Classes/Routing/Exception/NoHomepageException.php diff --git a/Neos.Neos/Classes/Routing/Exception/NoHomepageException.php b/Neos.Neos/Classes/Routing/Exception/NoHomepageException.php deleted file mode 100644 index e7ab63f3907..00000000000 --- a/Neos.Neos/Classes/Routing/Exception/NoHomepageException.php +++ /dev/null @@ -1,24 +0,0 @@ - Date: Wed, 7 Feb 2024 17:02:18 +0100 Subject: [PATCH 05/15] TASK: Throw dedicated `SiteDetectionFailedException` exception --- .../SiteDetection/SiteDetectionFailedException.php | 13 +++++++++++++ .../SiteDetection/SiteDetectionResult.php | 9 ++++----- 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionFailedException.php diff --git a/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionFailedException.php b/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionFailedException.php new file mode 100644 index 00000000000..9d15d8c271e --- /dev/null +++ b/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionFailedException.php @@ -0,0 +1,13 @@ +getValue(self::ROUTINGPARAMETER_SITENODENAME); $contentRepositoryId = $routeParameters->getValue(self::ROUTINGPARAMETER_CONTENTREPOSITORYID); - if ($siteNodeName === null || $contentRepositoryId === null) { - throw new \RuntimeException( + if (!is_string($siteNodeName) || !is_string($contentRepositoryId)) { + throw new SiteDetectionFailedException( 'Current site and content repository could not be extracted from the Request.' - . ' The SiteDetectionMiddleware was not able to determine the site!' + . ' The SiteDetectionMiddleware was not able to determine the site!', + 1699459565 ); } - assert(is_string($siteNodeName)); - assert(is_string($contentRepositoryId)); return new self( SiteNodeName::fromString($siteNodeName), ContentRepositoryId::fromString($contentRepositoryId) From a2dd063fde0c5b3ccf8c96b6b260870ad63f6d17 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:02:45 +0100 Subject: [PATCH 06/15] BUGFIX: Graceful site detection and early return --- .../EventSourcedFrontendNodeRoutePartHandler.php | 8 ++++++-- .../Classes/Service/EditorContentStreamZookeeper.php | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Neos.Neos/Classes/FrontendRouting/EventSourcedFrontendNodeRoutePartHandler.php b/Neos.Neos/Classes/FrontendRouting/EventSourcedFrontendNodeRoutePartHandler.php index 56f414cbf53..d2d592f61fa 100644 --- a/Neos.Neos/Classes/FrontendRouting/EventSourcedFrontendNodeRoutePartHandler.php +++ b/Neos.Neos/Classes/FrontendRouting/EventSourcedFrontendNodeRoutePartHandler.php @@ -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; @@ -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) { @@ -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 { diff --git a/Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php b/Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php index 2d1095bfe41..8ee55645c69 100644 --- a/Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php +++ b/Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php @@ -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; @@ -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; @@ -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( From e82f705f448538044559cad531388a8356d9e79e Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:03:07 +0100 Subject: [PATCH 07/15] BUGFIX: Use the welcome view if the SiteDetectionFailed --- Neos.Neos/Configuration/Settings.yaml | 2 +- Neos.Neos/Resources/Private/Translations/en/Main.xlf | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Neos.Neos/Configuration/Settings.yaml b/Neos.Neos/Configuration/Settings.yaml index b1d965074f0..81127c05eb5 100755 --- a/Neos.Neos/Configuration/Settings.yaml +++ b/Neos.Neos/Configuration/Settings.yaml @@ -481,7 +481,7 @@ Neos: noHomepageException: matchingExceptionClassNames: - - Neos\Neos\Routing\Exception\NoHomepageException + - Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionFailedException options: *welcomeTemplate debugger: ignoredClasses: diff --git a/Neos.Neos/Resources/Private/Translations/en/Main.xlf b/Neos.Neos/Resources/Private/Translations/en/Main.xlf index b793d2eec42..67649a87f32 100644 --- a/Neos.Neos/Resources/Private/Translations/en/Main.xlf +++ b/Neos.Neos/Resources/Private/Translations/en/Main.xlf @@ -695,6 +695,10 @@ Sorry, the page you requested was not found. + + You might want to import or create a new site in the setup. + + Invalid NodeType From 29354959ad046f01bd05b38ac1a92b72d76155a4 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:58:32 +0100 Subject: [PATCH 08/15] BUGFIX: Prevent the Fusion Exception view to return blank page --- .../Classes/View/FusionExceptionView.php | 73 ++++++++++++------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/Neos.Neos/Classes/View/FusionExceptionView.php b/Neos.Neos/Classes/View/FusionExceptionView.php index 59cddcd535d..c0c990a75e9 100644 --- a/Neos.Neos/Classes/View/FusionExceptionView.php +++ b/Neos.Neos/Classes/View/FusionExceptionView.php @@ -29,6 +29,7 @@ use Neos\Flow\Mvc\View\AbstractView; use Neos\Flow\ObjectManagement\ObjectManagerInterface; use Neos\Flow\Security\Context as SecurityContext; +use Neos\FluidAdaptor\View\StandaloneView; use Neos\Fusion\Core\FusionGlobals; use Neos\Fusion\Core\Runtime as FusionRuntime; use Neos\Fusion\Core\RuntimeFactory; @@ -38,6 +39,7 @@ use Neos\Neos\Domain\Repository\SiteRepository; use Neos\Neos\Domain\Service\FusionService; use Neos\Neos\Domain\Service\SiteNodeUtility; +use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionFailedException; use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; class FusionExceptionView extends AbstractView @@ -107,7 +109,12 @@ public function render() $httpRequest = $requestHandler->getHttpRequest(); - $siteDetectionResult = SiteDetectionResult::fromRequest($httpRequest); + try { + $siteDetectionResult = SiteDetectionResult::fromRequest($httpRequest); + } catch (SiteDetectionFailedException) { + return $this->renderErrorWelcomeScreen(); + } + $contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId); $fusionExceptionViewInternals = $this->contentRepositoryRegistry->buildService( $siteDetectionResult->contentRepositoryId, @@ -128,6 +135,10 @@ public function render() ); } + if (!$currentSiteNode) { + return $this->renderErrorWelcomeScreen(); + } + $request = ActionRequest::fromHttpRequest($httpRequest); $request->setControllerPackageKey('Neos.Neos'); $request->setFormat('html'); @@ -144,32 +155,28 @@ public function render() $securityContext = $this->objectManager->get(SecurityContext::class); $securityContext->setRequest($request); - if ($currentSiteNode) { - $fusionRuntime = $this->getFusionRuntime($currentSiteNode, $controllerContext); - - $this->setFallbackRuleFromDimension($dimensionSpacePoint); - - $fusionRuntime->pushContextArray(array_merge( - $this->variables, - [ - 'node' => $currentSiteNode, - 'documentNode' => $currentSiteNode, - 'site' => $currentSiteNode, - 'editPreviewMode' => null - ] - )); - - try { - $output = $fusionRuntime->render('error'); - return $this->extractBodyFromOutput($output); - } catch (RuntimeException $exception) { - throw $exception->getPrevious() ?: $exception; - } finally { - $fusionRuntime->popContext(); - } + $fusionRuntime = $this->getFusionRuntime($currentSiteNode, $controllerContext); + + $this->setFallbackRuleFromDimension($dimensionSpacePoint); + + $fusionRuntime->pushContextArray(array_merge( + $this->variables, + [ + 'node' => $currentSiteNode, + 'documentNode' => $currentSiteNode, + 'site' => $currentSiteNode, + 'editPreviewMode' => null + ] + )); + + try { + $output = $fusionRuntime->render('error'); + return $this->extractBodyFromOutput($output); + } catch (RuntimeException $exception) { + throw $exception->getPrevious() ?: $exception; + } finally { + $fusionRuntime->popContext(); } - - return ''; } /** @@ -219,4 +226,18 @@ protected function getFusionRuntime( } return $this->fusionRuntime; } + + private function renderErrorWelcomeScreen(): string + { + // in case no neos site being there or no site node we cannot continue with the fusion exception view, + // as we wouldn't know the site and cannot get the site's root.fusion + // instead we render the welcome screen directly + // Todo hack to use fluid. Requires the Welcome.html to be ported to Fusion. PR -> https://github.com/neos/neos-development-collection/pull/4880 + $view = StandaloneView::createWithOptions([ + 'templatePathAndFilename' => 'resource://Neos.Neos/Private/Templates/Error/Welcome.html', + 'layoutRootPaths' => ['resource://Neos.Neos/Private/Layouts/'] + ]); + $view->assignMultiple($this->variables); + return $view->render(); + } } From 9537cae9d58d5c16ef54de140044d823dffdb281 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:08:56 +0100 Subject: [PATCH 09/15] BUGFIX: Allow standalone instance of `FusionView` without request previously the `@package` resolving would always take place, even if not necessary, when all includes are fully specified. --- Neos.Fusion/Classes/View/FusionView.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Neos.Fusion/Classes/View/FusionView.php b/Neos.Fusion/Classes/View/FusionView.php index c1ba4337296..bf983346f4f 100644 --- a/Neos.Fusion/Classes/View/FusionView.php +++ b/Neos.Fusion/Classes/View/FusionView.php @@ -224,10 +224,13 @@ protected function getMergedFusionObjectTree(): FusionConfiguration */ public function getFusionPathPatterns(): array { - $packageKey = $this->getPackageKey(); $fusionPathPatterns = array_map( - function ($fusionPathPattern) use ($packageKey) { - return str_replace('@package', $packageKey, $fusionPathPattern); + function ($fusionPathPattern) { + if (!str_contains($fusionPathPattern, '@package')) { + return $fusionPathPattern; + } + + return str_replace('@package', $this->getPackageKey(), $fusionPathPattern); }, $this->getOption('fusionPathPatterns') ); @@ -247,8 +250,10 @@ protected function getPackageKey() if ($packageKey !== null) { return $packageKey; } else { - /** @var $request ActionRequest */ - $request = $this->controllerContext->getRequest(); + $request = $this->controllerContext?->getRequest(); + if (!$request) { + throw new \RuntimeException(sprintf('To resolve the @package in all fusionPathPatterns, either packageKey has to be specified, or the current request be available.')); + } return $request->getControllerPackageKey(); } } From 0c11068db54d19be000727762d6efd893146d528 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:10:49 +0100 Subject: [PATCH 10/15] TASK: Followup #4880 use fusion view instead of fluid for welcome rendering fallback --- Neos.Neos/Classes/View/FusionExceptionView.php | 9 ++++----- Neos.Neos/Resources/Private/Fusion/Error/Root.fusion | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Neos.Neos/Classes/View/FusionExceptionView.php b/Neos.Neos/Classes/View/FusionExceptionView.php index c0c990a75e9..23b006cca8a 100644 --- a/Neos.Neos/Classes/View/FusionExceptionView.php +++ b/Neos.Neos/Classes/View/FusionExceptionView.php @@ -29,7 +29,6 @@ use Neos\Flow\Mvc\View\AbstractView; use Neos\Flow\ObjectManagement\ObjectManagerInterface; use Neos\Flow\Security\Context as SecurityContext; -use Neos\FluidAdaptor\View\StandaloneView; use Neos\Fusion\Core\FusionGlobals; use Neos\Fusion\Core\Runtime as FusionRuntime; use Neos\Fusion\Core\RuntimeFactory; @@ -232,10 +231,10 @@ private function renderErrorWelcomeScreen(): string // in case no neos site being there or no site node we cannot continue with the fusion exception view, // as we wouldn't know the site and cannot get the site's root.fusion // instead we render the welcome screen directly - // Todo hack to use fluid. Requires the Welcome.html to be ported to Fusion. PR -> https://github.com/neos/neos-development-collection/pull/4880 - $view = StandaloneView::createWithOptions([ - 'templatePathAndFilename' => 'resource://Neos.Neos/Private/Templates/Error/Welcome.html', - 'layoutRootPaths' => ['resource://Neos.Neos/Private/Layouts/'] + $view = \Neos\Fusion\View\FusionView::createWithOptions([ + 'fusionPath' => 'Neos/Fusion/NotFoundExceptions', + 'fusionPathPatterns' => ['resource://Neos.Neos/Private/Fusion/Error/Root.fusion'], + 'enableContentCache' => false, ]); $view->assignMultiple($this->variables); return $view->render(); diff --git a/Neos.Neos/Resources/Private/Fusion/Error/Root.fusion b/Neos.Neos/Resources/Private/Fusion/Error/Root.fusion index 0599d2a6abe..05461f5a562 100644 --- a/Neos.Neos/Resources/Private/Fusion/Error/Root.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Error/Root.fusion @@ -11,3 +11,8 @@ Neos.Fusion.DatabaseConnectionExceptions = Neos.Neos:Error.View.Welcome { exception = ${exception} renderingGroupName = ${renderingOptions.renderingGroup} } + +Neos.Fusion.NotFoundExceptions = Neos.Neos:Error.View.Welcome { + exception = ${exception} + renderingGroupName = ${renderingOptions.renderingGroup} +} From e04053c73d3c9bd66cb4baa37ec135ed28f16399 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:53:13 +0100 Subject: [PATCH 11/15] TASK: Remove deprecated `editPreviewMode` variable The TypoScript context variable `editPreviewMode` was deprecated in favour of `${documentNode.context.currentRenderingMode.name}` With neos 9 that again was removed in favour of the fusion global `renderingMode`. https://github.com/neos/neos-development-collection/pull/4505 --- Neos.Neos/Classes/View/FusionExceptionView.php | 3 +-- Neos.Neos/Classes/View/FusionView.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Neos.Neos/Classes/View/FusionExceptionView.php b/Neos.Neos/Classes/View/FusionExceptionView.php index 23b006cca8a..a3bfc66d2c7 100644 --- a/Neos.Neos/Classes/View/FusionExceptionView.php +++ b/Neos.Neos/Classes/View/FusionExceptionView.php @@ -163,8 +163,7 @@ public function render() [ 'node' => $currentSiteNode, 'documentNode' => $currentSiteNode, - 'site' => $currentSiteNode, - 'editPreviewMode' => null + 'site' => $currentSiteNode ] )); diff --git a/Neos.Neos/Classes/View/FusionView.php b/Neos.Neos/Classes/View/FusionView.php index 7cf490e96f5..6ff365b5127 100644 --- a/Neos.Neos/Classes/View/FusionView.php +++ b/Neos.Neos/Classes/View/FusionView.php @@ -77,8 +77,7 @@ public function render(): string|ResponseInterface $fusionRuntime->pushContextArray([ 'node' => $currentNode, 'documentNode' => $this->getClosestDocumentNode($currentNode) ?: $currentNode, - 'site' => $currentSiteNode, - 'editPreviewMode' => $this->variables['editPreviewMode'] ?? null + 'site' => $currentSiteNode ]); try { $output = $fusionRuntime->render($this->fusionPath); From d7f04640fc39cd386f6f4a3af987a1f75fdafac2 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 16 Feb 2024 09:09:56 +0100 Subject: [PATCH 12/15] TASK: Fix phpstan --- Neos.Neos/Classes/View/FusionExceptionView.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Neos.Neos/Classes/View/FusionExceptionView.php b/Neos.Neos/Classes/View/FusionExceptionView.php index a3bfc66d2c7..bf4807b0e65 100644 --- a/Neos.Neos/Classes/View/FusionExceptionView.php +++ b/Neos.Neos/Classes/View/FusionExceptionView.php @@ -92,7 +92,7 @@ class FusionExceptionView extends AbstractView protected DomainRepository $domainRepository; /** - * @return string + * @return mixed * @throws \Neos\Flow\I18n\Exception\InvalidLocaleIdentifierException * @throws \Neos\Fusion\Exception * @throws \Neos\Neos\Domain\Exception @@ -225,7 +225,7 @@ protected function getFusionRuntime( return $this->fusionRuntime; } - private function renderErrorWelcomeScreen(): string + private function renderErrorWelcomeScreen(): mixed { // in case no neos site being there or no site node we cannot continue with the fusion exception view, // as we wouldn't know the site and cannot get the site's root.fusion From 2b7ab8011035c1409b1b7111472456da47077c81 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:27:54 +0100 Subject: [PATCH 13/15] TASK: Remove `noHomepageException` rendering group After the previous adjustments the `SiteDetectionFailedException` will only be thrown in fewer cases, the only real reproducible the `/neos/content` route. The rendering group is a bit overkill only for this thing and also might swallow 500 errors that should be presented as is and not wrapped by a vibrant welcome page. The ui should be adjusted instead. https://github.com/neos/neos-ui/issues/3721 --- Neos.Neos/Configuration/Settings.yaml | 7 +------ Neos.Neos/Resources/Private/Translations/en/Main.xlf | 10 ---------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/Neos.Neos/Configuration/Settings.yaml b/Neos.Neos/Configuration/Settings.yaml index 81127c05eb5..5ad7785a511 100755 --- a/Neos.Neos/Configuration/Settings.yaml +++ b/Neos.Neos/Configuration/Settings.yaml @@ -471,18 +471,13 @@ Neos: - Neos\Flow\Persistence\Doctrine\Exception\DatabaseException - Neos\Flow\Persistence\Doctrine\Exception\DatabaseConnectionException - Neos\Flow\Persistence\Doctrine\Exception\DatabaseStructureException - options: &welcomeTemplate + options: viewClassName: Neos\Fusion\View\FusionView viewOptions: fusionPath: 'Neos/Fusion/DatabaseConnectionExceptions' fusionPathPatterns: ['resource://Neos.Neos/Private/Fusion/Error/Root.fusion'] enableContentCache: false templatePathAndFilename: ~ - - noHomepageException: - matchingExceptionClassNames: - - Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionFailedException - options: *welcomeTemplate debugger: ignoredClasses: Neos\\Neos\\Domain\\Service\\ContentContextFactory: true diff --git a/Neos.Neos/Resources/Private/Translations/en/Main.xlf b/Neos.Neos/Resources/Private/Translations/en/Main.xlf index 67649a87f32..78c048608d6 100644 --- a/Neos.Neos/Resources/Private/Translations/en/Main.xlf +++ b/Neos.Neos/Resources/Private/Translations/en/Main.xlf @@ -669,16 +669,6 @@ Technical Information - - Missing Homepage - - - Either no site has been defined, the site does not contain a homepage or the active site couldn't be determined. - - - You might want to set the site's domain or import a new site in the setup. - - Database Error From 002ee3de366edbe052bca6de267cb407c69bc439 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:34:03 +0100 Subject: [PATCH 14/15] TASK: Docs `SiteDetectionFailedException` --- .../SiteDetection/SiteDetectionFailedException.php | 3 +-- .../SiteDetection/SiteDetectionResult.php | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionFailedException.php b/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionFailedException.php index 9d15d8c271e..0c770cf4b20 100644 --- a/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionFailedException.php +++ b/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionFailedException.php @@ -5,8 +5,7 @@ namespace Neos\Neos\FrontendRouting\SiteDetection; /** - * Neos was probably not setup yet. - * No existent site entity will for example cause this issue. + * This error will be thrown in {@see SiteDetectionResult::fromRequest()} */ class SiteDetectionFailedException extends \RuntimeException { diff --git a/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionResult.php b/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionResult.php index 0d2365b447e..6816ebf1856 100644 --- a/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionResult.php +++ b/Neos.Neos/Classes/FrontendRouting/SiteDetection/SiteDetectionResult.php @@ -41,7 +41,11 @@ public static function create( * Helper to retrieve the previously resolved Site and ContentRepository instance. * * @param ServerRequestInterface $request - * @return static + * @throws SiteDetectionFailedException This error will be thrown if a request is passed + * where the site detection middleware did not store a site in. + * This is likely the case if the request is a mock or + * if no site entity exists because Neos was not setup. + * * @api */ public static function fromRequest(ServerRequestInterface $request): self @@ -52,6 +56,9 @@ public static function fromRequest(ServerRequestInterface $request): self return self::fromRouteParameters($routeParameters); } + /** + * @throws SiteDetectionFailedException + */ public static function fromRouteParameters(RouteParameters $routeParameters): self { $siteNodeName = $routeParameters->getValue(self::ROUTINGPARAMETER_SITENODENAME); From deb815eaf6f3b15bd67c42af513d7456ebd91bb2 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:37:47 +0100 Subject: [PATCH 15/15] TASK: Use tabs in xlf?? --- Neos.Neos/Resources/Private/Translations/en/Main.xlf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Neos.Neos/Resources/Private/Translations/en/Main.xlf b/Neos.Neos/Resources/Private/Translations/en/Main.xlf index 78c048608d6..a3832801bef 100644 --- a/Neos.Neos/Resources/Private/Translations/en/Main.xlf +++ b/Neos.Neos/Resources/Private/Translations/en/Main.xlf @@ -685,9 +685,9 @@ Sorry, the page you requested was not found. - - You might want to import or create a new site in the setup. - + + You might want to import or create a new site in the setup. + Invalid NodeType