[CORE] Fix logging of very early failures

This commit is contained in:
Alexei Sorokin 2019-09-13 12:11:43 +03:00
parent 4afaad3df5
commit 1f2f57b03b
2 changed files with 6 additions and 2 deletions

View File

@ -1417,14 +1417,14 @@ function common_path($relative, $ssl=false, $addSession=true)
} elseif (common_config('site', 'server')) { } elseif (common_config('site', 'server')) {
$serverpart = common_config('site', 'server'); $serverpart = common_config('site', 'server');
} else { } else {
common_log(LOG_ERR, 'Site server not configured, unable to determine site name.'); throw new ServerException('Site server not configured, unable to determine site name.');
} }
} else { } else {
$proto = 'http'; $proto = 'http';
if (common_config('site', 'server')) { if (common_config('site', 'server')) {
$serverpart = common_config('site', 'server'); $serverpart = common_config('site', 'server');
} else { } else {
common_log(LOG_ERR, 'Site server not configured, unable to determine site name.'); throw new ServerException('Site server not configured, unable to determine site name.');
} }
} }
@ -2151,6 +2151,9 @@ function common_negotiate_type($cprefs, $sprefs)
function common_config($main, $sub=null) function common_config($main, $sub=null)
{ {
global $config; global $config;
if (is_null($config)) {
throw new ServerException('common_config was invoked before config.php was read');
}
if (is_null($sub)) { if (is_null($sub)) {
// Return the config category array // Return the config category array
return array_key_exists($main, $config) ? $config[$main] : []; return array_key_exists($main, $config) ? $config[$main] : [];

View File

@ -156,6 +156,7 @@ function handleError($error)
} catch (Exception $e) { } catch (Exception $e) {
// TRANS: Error message. // TRANS: Error message.
echo _('An error occurred.'); echo _('An error occurred.');
error_log('Uncaught Exception: ' . $error);
exit(-1); exit(-1);
} }
exit(-1); exit(-1);