Update request URI scheme with config value
Removes the Config::isHttps() call from constructor as PmaAbsoluteUri is not available yet. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
74ba4f17b0
commit
fd88454d08
@ -119,6 +119,8 @@ final class Common
|
||||
return;
|
||||
}
|
||||
|
||||
$request = self::updateUriScheme($config, $request);
|
||||
|
||||
if ($route !== '/messages') {
|
||||
try {
|
||||
// Include session handling after the globals, to prevent overwriting.
|
||||
@ -647,4 +649,15 @@ final class Common
|
||||
'error_message' => $message,
|
||||
]);
|
||||
}
|
||||
|
||||
private static function updateUriScheme(Config $config, ServerRequest $request): ServerRequest
|
||||
{
|
||||
$uriScheme = $config->isHttps() ? 'https' : 'http';
|
||||
$uri = $request->getUri();
|
||||
if ($uri->getScheme() === $uriScheme) {
|
||||
return $request;
|
||||
}
|
||||
|
||||
return $request->withUri($uri->withScheme($uriScheme));
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ use function implode;
|
||||
use function ini_get;
|
||||
use function intval;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_dir;
|
||||
use function is_int;
|
||||
use function is_numeric;
|
||||
@ -93,15 +94,10 @@ class Config
|
||||
/** @var mixed[] */
|
||||
public array $defaultServer = [];
|
||||
|
||||
private bool $isHttps;
|
||||
private bool $isHttps = false;
|
||||
|
||||
private Settings|null $config = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->isHttps = $this->isHttps();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $source source to read config from
|
||||
*
|
||||
@ -117,6 +113,7 @@ class Config
|
||||
// other settings, independent of config file, comes in
|
||||
$this->checkSystem();
|
||||
|
||||
$this->isHttps = $this->isHttps();
|
||||
$this->baseSettings = $this->settings;
|
||||
}
|
||||
|
||||
@ -783,9 +780,10 @@ class Config
|
||||
*/
|
||||
public function isHttps(): bool
|
||||
{
|
||||
/** @var mixed $isHttps */
|
||||
$isHttps = $this->get('is_https');
|
||||
if ($isHttps !== null) {
|
||||
return (bool) $isHttps;
|
||||
if (is_bool($isHttps)) {
|
||||
return $isHttps;
|
||||
}
|
||||
|
||||
$url = $this->get('PmaAbsoluteUri');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user