diff --git a/extension/Classes/Core/Database/DatabaseUpdate.php b/extension/Classes/Core/Database/DatabaseUpdate.php index 2a430a86c5e4adc8fdf7a1dcb7cc44f12facf5f2..a49e8897add9a44d73ac4dc264550ab3eff586cb 100644 --- a/extension/Classes/Core/Database/DatabaseUpdate.php +++ b/extension/Classes/Core/Database/DatabaseUpdate.php @@ -91,7 +91,7 @@ class DatabaseUpdate { foreach ($arr as $row) { if (isset($row['Comment'])) { parse_str($row['Comment'], $arr); - if (($arr[QFQ_VERSION_KEY] ?? '') !== '' AND (version_compare($arr[QFQ_VERSION_KEY], $found) == 1)) { + if (($arr[QFQ_VERSION_KEY] ?? '') !== '' && (version_compare($arr[QFQ_VERSION_KEY], $found) == 1)) { $found = $arr; } } else { @@ -204,7 +204,7 @@ class DatabaseUpdate { } /** - * Check Typo3 config if values needs to be updated. + * Check Typo3 config, if values needs to be updated. * This is typically necessary if default config values change, to guarantee existing installations behave in legacy mode. * * @param $old @@ -212,7 +212,19 @@ class DatabaseUpdate { */ private function checkT3QfqConfig($old, $new) { - if ($new == $old || $old===false ) { + if ($new == $old || $old === false) { + // Set baseUrl default + if ($GLOBALS["_SERVER"]["SCRIPT_URI"] !== '') { + if ($GLOBALS["TYPO3_CONF_VARS"]["EXTENSIONS"]["qfq"]["baseUrl"] === '') { + $fullUrl = parse_url($GLOBALS["_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. + } + } return; } @@ -406,7 +418,7 @@ class DatabaseUpdate { $qfqFunctionSqlRelToApp = Path::appToExt('Classes/Sql/' . QFQ_FUNCTION_SQL); - if ($functionHash !== null AND $functionsHashTest === $functionHash) { + if ($functionHash !== null and $functionsHashTest === $functionHash) { return $functionHash; } else { $errorMsg[ERROR_MESSAGE_TO_USER] = 'Error while updating qfq.'; diff --git a/extension/Classes/Core/Store/Config.php b/extension/Classes/Core/Store/Config.php index ee5127d9798d2e5c7e01ca6d7c55aa4f635d5386..98862eb7653829b3e8819ccce0274f6c5a5a0b73 100644 --- a/extension/Classes/Core/Store/Config.php +++ b/extension/Classes/Core/Store/Config.php @@ -79,8 +79,10 @@ class Config { $absoluteConfigFilePath = $PhpUnitOverloadAbsoluteConfigFilePath === '' ? Path::absoluteConf(CONFIG_QFQ_JSON) : $PhpUnitOverloadAbsoluteConfigFilePath; if (!file_exists($absoluteConfigFilePath)) { HelperFile::createPathRecursive(Path::absoluteConf()); - HelperFile::file_put_contents(Path::absoluteConf(CONFIG_QFQ_JSON_EXAMPLE), json_encode(self::CONFIG_REQUIRED_TEMPLATE, JSON_PRETTY_PRINT)); - Thrower::userFormException("Please create qfq config file '" . CONFIG_QFQ_JSON . "' in the conf directory which is inside the project directory. Example config file '" . CONFIG_QFQ_JSON_EXAMPLE . "' was created in conf directory.", "Project directory: " . Path::absoluteProject()); + HelperFile::file_put_contents(Path::absoluteConf(CONFIG_QFQ_JSON_EXAMPLE), + json_encode(self::CONFIG_REQUIRED_TEMPLATE, JSON_PRETTY_PRINT)); + + Thrower::userFormException("Please create qfq config file '" . CONFIG_QFQ_JSON . "' in path fileadmin/protected/qfqProject/conf/ which is inside the project directory. Example config file '" . CONFIG_QFQ_JSON_EXAMPLE . "' was created in conf directory.", "Project directory: " . Path::absoluteProject()); } $config = HelperFile::json_decode(HelperFile::file_get_contents($absoluteConfigFilePath));