From 31c5ab20693a59570fe4f9d169fa3e5917a161e1 Mon Sep 17 00:00:00 2001 From: Kunal Hari Date: Tue, 13 Apr 2021 14:06:21 +1200 Subject: [PATCH] [BUGFIX] Prevent call getHeader() on null HTTPRequest object --- src/Control/Director.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Control/Director.php b/src/Control/Director.php index f75d8182d..eac732e44 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -938,12 +938,13 @@ class Director implements TemplateGlobalProvider public static function absoluteBaseURLWithAuth(HTTPRequest $request = null) { // Detect basic auth - $user = $request->getHeader('PHP_AUTH_USER'); - if ($user) { - $password = $request->getHeader('PHP_AUTH_PW'); - $login = sprintf("%s:%s@", $user, $password) ; - } else { - $login = ''; + $login = ''; + if ($request) { + $user = $request->getHeader('PHP_AUTH_USER'); + if ($user) { + $password = $request->getHeader('PHP_AUTH_PW'); + $login = sprintf("%s:%s@", $user, $password); + } } return Director::protocol($request) . $login . static::host($request) . Director::baseURL();