From 3605afc529a6c7bedbe05aed3bd3b17d5915e17b Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Tue, 14 Jan 2025 15:01:23 +0100 Subject: [PATCH] Improve SelfTest for Base URL --- protected/humhub/libs/SelfTest.php | 12 ++---------- .../humhub/modules/installer/libs/InitialData.php | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/protected/humhub/libs/SelfTest.php b/protected/humhub/libs/SelfTest.php index 32c727756a..b5b3f29db7 100644 --- a/protected/humhub/libs/SelfTest.php +++ b/protected/humhub/libs/SelfTest.php @@ -15,6 +15,7 @@ use humhub\modules\marketplace\Module; use humhub\services\MigrationService; use Yii; use yii\helpers\UnsetArrayValue; +use yii\helpers\Url; /** * SelfTest is a helper class which checks all dependencies of the application. @@ -430,16 +431,7 @@ class SelfTest } $title = Yii::t('AdminModule.information', 'Settings') . ' - ' . Yii::t('AdminModule.information', 'Base URL'); - $scheme = Yii::$app->request->getIsSecureConnection() ? 'https' : 'http'; - $port = Yii::$app->request->getServerPort(); - $currentBaseUrl = $scheme . '://' . preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST']) - . ( - ($scheme === 'https' && $port == 443) || - ($scheme === 'http' && $port == 80) - ? '' - : ':' . $port - ) - . ($_SERVER['BASE'] ?? ''); + $currentBaseUrl = Url::base(true); if ($currentBaseUrl === Yii::$app->settings->get('baseUrl')) { $checks[] = [ 'title' => $title, diff --git a/protected/humhub/modules/installer/libs/InitialData.php b/protected/humhub/modules/installer/libs/InitialData.php index 6f1472ad8e..96b80317e6 100644 --- a/protected/humhub/modules/installer/libs/InitialData.php +++ b/protected/humhub/modules/installer/libs/InitialData.php @@ -21,7 +21,7 @@ use humhub\modules\user\models\ProfileField; use humhub\modules\user\models\ProfileFieldCategory; use Yii; use yii\base\Exception; -use yii\helpers\BaseUrl; +use yii\helpers\Url; /** * InitialData @@ -37,7 +37,7 @@ class InitialData return; } - Yii::$app->settings->set('baseUrl', BaseUrl::base(true)); + Yii::$app->settings->set('baseUrl', Url::base(true)); Yii::$app->settings->set('paginationSize', 10); Yii::$app->settings->set('displayNameFormat', '{profile.firstname} {profile.lastname}'); Yii::$app->settings->set('horImageScrollOnMobile', true);