Nicely exit in case of an early PHP type crash

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2023-02-20 18:12:02 +01:00
parent 6b35829406
commit 4ce69f3a3d
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
3 changed files with 18 additions and 7 deletions

View File

@ -111,8 +111,12 @@ class Header
$this->bodyId = '';
$this->title = '';
$this->console = new Console();
$this->menu = new Menu($dbi, $db ?? '', $table ?? '');
$this->menuEnabled = true;
$this->menuEnabled = false;
if ($dbi !== null) {
$this->menuEnabled = true;
$this->menu = new Menu($dbi, $db ?? '', $table ?? '');
}
$this->warningsEnabled = true;
$this->scripts = new Scripts();
$this->addDefaultScripts();
@ -191,8 +195,8 @@ class Header
'LoginCookieValidity' => $GLOBALS['cfg']['LoginCookieValidity'],
'session_gc_maxlifetime' => (int) ini_get('session.gc_maxlifetime'),
'logged_in' => isset($dbi) ? $dbi->isConnected() : false,
'is_https' => $GLOBALS['config']->isHttps(),
'rootPath' => $GLOBALS['config']->getRootPath(),
'is_https' => $GLOBALS['config'] !== null && $GLOBALS['config']->isHttps(),
'rootPath' => $GLOBALS['config'] !== null && $GLOBALS['config']->getRootPath(),
'arg_separator' => Url::getArgSeparator(),
'version' => Version::VERSION,
];

View File

@ -290,9 +290,16 @@ class ResponseRenderer
// if its content was already rendered
// and, in this case, the header will be
// in the content part of the request
$retval = $this->header->getDisplay();
$retval = '';
if ($this->header !== null) {
$retval .= $this->header->getDisplay();
}
$retval .= $this->HTML;
$retval .= $this->footer->getDisplay();
if ($this->footer !== null) {
$retval .= $this->footer->getDisplay();
}
return $retval;
}

View File

@ -249,7 +249,7 @@ class Url
$separator = self::getArgSeparator();
if (! $encrypt || ! $config->get('URLQueryEncryption')) {
if (! $encrypt || $config === null || ! $config->get('URLQueryEncryption')) {
return http_build_query($params, '', $separator);
}