fix(legacy): do not rely on undefined SERVER_NAME (#2031)

This commit is contained in:
Jonas L 2022-08-09 20:24:09 +02:00 committed by GitHub
parent 631a7956ea
commit 45c283504e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 34 deletions

View file

@ -516,23 +516,7 @@ SQL;
*/
public function getFileUrl()
{
$protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
$serverName = $_SERVER['SERVER_NAME'];
$serverPort = $_SERVER['SERVER_PORT'];
$subDir = Config::getBasePath();
if ($protocol === 'https' && $serverPort == 80) {
$serverPort = 443;
}
if ($subDir[0] === '/') {
$subDir = substr($subDir, 1, strlen($subDir) - 1);
}
$baseUrl = "{$protocol}://{$serverName}:{$serverPort}/{$subDir}";
return $this->getRelativeFileUrl($baseUrl);
return $this->getRelativeFileUrl(Config::getPublicUrl());
}
/**