From e10bd87a12426ca8cef2a9cc61a21d20a51d76c6 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Tue, 29 Oct 2024 15:19:58 +0100 Subject: [PATCH] Fix Base URL detection on Prerequisites (#7279) * Fix Base URL detection on Prerequisites * Autocommit PHP CS Fixer --- protected/humhub/config/assets-prod.php | 2 +- protected/humhub/libs/SelfTest.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/protected/humhub/config/assets-prod.php b/protected/humhub/config/assets-prod.php index 389928df24..d7ba6209cb 100644 --- a/protected/humhub/config/assets-prod.php +++ b/protected/humhub/config/assets-prod.php @@ -532,4 +532,4 @@ return [ 'defer', ], ], -]; \ No newline at end of file +]; diff --git a/protected/humhub/libs/SelfTest.php b/protected/humhub/libs/SelfTest.php index 577c20649b..c37095d4f4 100644 --- a/protected/humhub/libs/SelfTest.php +++ b/protected/humhub/libs/SelfTest.php @@ -437,9 +437,13 @@ class SelfTest ? ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === 1 || $_SERVER['SERVER_PORT'] == $sslPort ? 'https' : 'http') : ($_SERVER['SERVER_PORT'] == $sslPort ? 'https' : 'http') ); - $currentBaseUrl = $scheme . '://' . $_SERVER['HTTP_HOST'] - . (($scheme === 'https' && $_SERVER['SERVER_PORT'] == $sslPort) || - ($scheme === 'http' && $_SERVER['SERVER_PORT'] == $httpPort) ? '' : ':' . $_SERVER['SERVER_PORT']) + $currentBaseUrl = $scheme . '://' . preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST']) + . ( + ($scheme === 'https' && $_SERVER['SERVER_PORT'] == $sslPort) || + ($scheme === 'http' && $_SERVER['SERVER_PORT'] == $httpPort) + ? '' + : ':' . $_SERVER['SERVER_PORT'] + ) . ($_SERVER['BASE'] ?? ''); if ($currentBaseUrl === Yii::$app->settings->get('baseUrl')) { $checks[] = [