From 332178acf7ca3f174155de88426eb76593377ec4 Mon Sep 17 00:00:00 2001
From: enured <enis.nuredini@uzh.ch>
Date: Thu, 23 Dec 2021 14:25:15 +0100
Subject: [PATCH] B13562. Place to set default from baseUrl is now changed from
 DatabaseUpdate to Config file and code is costumized.

---
 extension/Classes/Core/Store/Config.php | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/extension/Classes/Core/Store/Config.php b/extension/Classes/Core/Store/Config.php
index ee5127d97..c2e5a2b83 100644
--- a/extension/Classes/Core/Store/Config.php
+++ b/extension/Classes/Core/Store/Config.php
@@ -15,6 +15,7 @@ use IMATHUZH\Qfq\Core\Helper\OnArray;
 use IMATHUZH\Qfq\Core\Helper\OnString;
 use IMATHUZH\Qfq\Core\Helper\Path;
 use IMATHUZH\Qfq\Core\Helper\Support;
+use IMATHUZH\Qfq\Core\Typo3\T3Handler;
 
 /**
  * Class Config
@@ -98,6 +99,18 @@ class Config {
             $config = array_merge($configT3qfq, $config);
         }
 
+        // Set default from baseUrl if not given
+        if($config[SYSTEM_BASE_URL] === ''){
+            $fullUrl = parse_url($_SERVER["SCRIPT_URI"]);
+            $fullUrl['sections'] = explode('/', $fullUrl['path']);
+            $baseUrl = $fullUrl['scheme'].'://'.$fullUrl['host'];
+            for($i = 1; $i < sizeof($fullUrl['sections']) -1; $i++){
+                $baseUrl .= '/'.$fullUrl['sections'][$i];
+            }
+            T3Handler::updateT3QfqConfig(SYSTEM_BASE_URL, $baseUrl); //Legacy behaviour.
+            $config[SYSTEM_BASE_URL] = $baseUrl;
+        }
+
         $config = self::renameConfigElements($config);
         $config = self::setDefaults($config);
         self::checkDeprecated($config);
-- 
GitLab