From b5143ab36f4b2cbadcb4fe0fb063ff9d6fd958b1 Mon Sep 17 00:00:00 2001
From: Helmut Hummel <typo3@helhum.io>
Date: Mon, 27 Apr 2020 23:33:35 +0200
Subject: [PATCH] [TASK] Allow overriding current site url during installation

Especially to ease using the API on CLI,
we now add a request argument for the siteUrl
which is preferred over the current site url to
create a default site configuration.

Resolves: #91214
Releases: master
Change-Id: If00beb2550909c2334d99a61283c6d7f546b25d7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64329
Tested-by: Benjamin Franzke <bfr@qbus.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 .../install/Classes/Controller/InstallerController.php    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/install/Classes/Controller/InstallerController.php b/typo3/sysext/install/Classes/Controller/InstallerController.php
index 1f65e6616ec6..89b8cf0986fc 100644
--- a/typo3/sysext/install/Classes/Controller/InstallerController.php
+++ b/typo3/sysext/install/Classes/Controller/InstallerController.php
@@ -1360,8 +1360,14 @@ For each website you need a TypoScript template on the main page of your website
         if (!($normalizedParams instanceof NormalizedParams)) {
             $normalizedParams = NormalizedParams::createFromRequest($request);
         }
+        // Check for siteUrl, despite there currently is no UI to provide it,
+        // to allow TYPO3 Console (for TYPO3 v10) to set this value to something reasonable,
+        // because on cli there is no way to find out which hostname the site is supposed to have.
+        // In the future this controller should be refactored to a generic service, where site URL is
+        // just one input argument.
+        $siteUrl = $request->getParsedBody()['install']['values']['siteUrl'] ?? $normalizedParams->getSiteUrl();
 
         // Create a default site configuration called "main" as best practice
-        $this->siteConfiguration->createNewBasicSite($identifier, $rootPageId, $normalizedParams->getSiteUrl());
+        $this->siteConfiguration->createNewBasicSite($identifier, $rootPageId, $siteUrl);
     }
 }
-- 
GitLab