Merge pull request #9916 from chrometoasters/bugfix/absolute-base-url-generation

[BUGFIX] Prevent call getHeader() on null HTTPRequest object
This commit is contained in:
Loz Calver 2021-04-16 09:15:15 +01:00 committed by GitHub
commit 097da7aed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -938,12 +938,13 @@ class Director implements TemplateGlobalProvider
public static function absoluteBaseURLWithAuth(HTTPRequest $request = null)
{
// Detect basic auth
$login = '';
if ($request) {
$user = $request->getHeader('PHP_AUTH_USER');
if ($user) {
$password = $request->getHeader('PHP_AUTH_PW');
$login = sprintf("%s:%s@", $user, $password);
} else {
$login = '';
}
}
return Director::protocol($request) . $login . static::host($request) . Director::baseURL();