Improve SelfTest for Base URL

This commit is contained in:
Yuriy Bakhtin 2025-01-14 15:01:23 +01:00
parent c238611a65
commit 3605afc529
2 changed files with 4 additions and 12 deletions

View File

@ -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,

View File

@ -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);