Skip to content

Commit dedddfb

Browse files
committed
TASK: Check primary domain has scheme set
1 parent 195ef1f commit dedddfb

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Classes/NodeRendering/Render/DocumentRenderer.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,24 @@ private static function wrapInHttpMessage(string $output, ActionResponse $respon
285285
* @param NodeInterface $node
286286
* @param array $arguments
287287
* @return string The resolved URI for the given node
288+
* @throws \Exception
288289
*/
289290
protected function buildNodeUri(NodeInterface $node, array $arguments)
290291
{
291292
/** @var Site $currentSite */
292293
$currentSite = $node->getContext()->getCurrentSite();
293294
if (!$currentSite->hasActiveDomains()) {
294-
throw new \Exception("No configured domain!");
295+
throw new Exception(sprintf("Site %s has no active domain", $currentSite->getNodeName()), 1666684522);
295296
}
297+
$primaryDomain = $currentSite->getPrimaryDomain();
298+
if ((string)$primaryDomain->getScheme() === '') {
299+
throw new Exception(sprintf("Domain %s for site %s has no scheme defined", $primaryDomain->getHostname(), $currentSite->getNodeName()), 1666684523);
300+
}
301+
296302
// HINT: We cannot use a static URL here, but instead need to use an URL of the current site.
297303
// This is changed from the the old behavior, where we have changed the LinkingService in LinkingServiceAspect,
298304
// to properly generate the domain part of the routes - and this relies on the proper ControllerContext URI path.
299-
$baseControllerContext = $this->buildControllerContextAndSetBaseUri($currentSite->getPrimaryDomain()->__toString(), $node, $arguments);
305+
$baseControllerContext = $this->buildControllerContextAndSetBaseUri($primaryDomain->__toString(), $node, $arguments);
300306
$format = $arguments['@format'] ?? 'html';
301307
$uri = $this->linkingService->createNodeUri($baseControllerContext, $node, null, $format, true, $arguments, '', false, [], false);
302308
return $this->removeQueryPartFromUri($uri);

0 commit comments

Comments
 (0)