-
-
Notifications
You must be signed in to change notification settings - Fork 235
BUGFIX: Improve FusionView slow queries for current document and site #5597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 9.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,13 +72,7 @@ public function render(): ResponseInterface|StreamInterface | |
| { | ||
| $currentNode = $this->getCurrentNode(); | ||
|
|
||
| $subgraph = $this->contentRepositoryRegistry->subgraphForNode($currentNode); | ||
| $currentSiteNode = $subgraph->findClosestNode($currentNode->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE)); | ||
|
|
||
| if (!$currentSiteNode) { | ||
| throw new \RuntimeException('No site node found!', 1697053346); | ||
| } | ||
|
|
||
| $currentSiteNode = $this->getCurrentSiteNode(); | ||
| $fusionRuntime = $this->getFusionRuntime($currentSiteNode); | ||
|
|
||
| $this->setFallbackRuleFromDimension($currentNode->dimensionSpacePoint); | ||
|
|
@@ -165,6 +159,12 @@ public function getFusionPath() | |
|
|
||
| protected function getClosestDocumentNode(Node $node): ?Node | ||
| { | ||
| $nodeTypeManager = $this->contentRepositoryRegistry->get($node->contentRepositoryId)->getNodeTypeManager(); | ||
|
|
||
| // Skip expensive subgraph lookup if the node is already a document node | ||
| if ($nodeTypeManager->getNodeType($node->nodeTypeName)?->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)) { | ||
| return $node; | ||
| } | ||
| return $this->contentRepositoryRegistry->subgraphForNode($node) | ||
| ->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT)); | ||
| } | ||
|
|
@@ -175,11 +175,20 @@ protected function getClosestDocumentNode(Node $node): ?Node | |
| */ | ||
| protected function getCurrentSiteNode(): Node | ||
| { | ||
| $currentNode = $this->variables['site'] ?? null; | ||
| if (!$currentNode instanceof Node) { | ||
| throw new Exception('FusionView needs a variable \'site\' set with a Node object.', 1538996432); | ||
| $currentSiteNode = $this->variables['site'] ?? null; | ||
| if (!$currentSiteNode instanceof Node) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So previously this case failed and now we try to fetch the site? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now the 8.3 behaviour again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason why it affects performance is, that the method is called at least twice. |
||
| $currentNode = $this->getCurrentNode(); | ||
| $subgraph = $this->contentRepositoryRegistry->subgraphForNode($currentNode); | ||
| $currentSiteNode = $subgraph->findClosestNode( | ||
| $currentNode->aggregateId, | ||
| FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE) | ||
| ); | ||
| $this->assign('site', $currentSiteNode); | ||
| } | ||
| return $currentNode; | ||
| if (!$currentSiteNode) { | ||
| throw new \RuntimeException('No site node found!', 1697053346); | ||
| } | ||
| return $currentSiteNode; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we should not need the node type manager here because if the view is used in the controller where we only route to documents we can trust the input and not be paranoid.
(asking things the node type manager loads and initialises the configuration which is also work which is ideally not part of the rendering?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes as with all those variables, the controller should supply them and the view should complain if not. Though I think in this case the Neos FusionView accepted any kind of node so far.
I would like to fix this for 9.x if we agree on the breakinesslevel.