Moved 503 check higher up into the startup process.

Since it no longer depends on Twig we don't have to initialise that, removing further points of failure.
This commit is contained in:
flash 2020-05-26 18:59:22 +00:00
parent e19c5a68ba
commit 737be27198

View file

@ -138,6 +138,15 @@ if(!mb_check_encoding()) {
ob_start();
if(file_exists(MSZ_ROOT . '/.migrating')) {
http_response_code(503);
if(!isset($_GET['_check'])) {
header('Content-Type: text/html; charset-utf-8');
echo file_get_contents(MSZ_ROOT . '/templates/503.html');
}
exit;
}
if(!is_readable(MSZ_STORAGE) || !is_writable(MSZ_STORAGE)) {
echo 'Cannot access storage directory.';
exit;
@ -161,15 +170,6 @@ Template::set('globals', [
Template::addPath(MSZ_ROOT . '/templates');
if(file_exists(MSZ_ROOT . '/.migrating')) {
http_response_code(503);
if(!isset($_GET['_check'])) {
header('Content-Type: text/html; charset-utf-8');
echo file_get_contents(MSZ_ROOT . '/templates/503.html');
}
exit;
}
if(isset($_COOKIE['msz_uid']) && isset($_COOKIE['msz_sid'])) {
$authToken = (new AuthToken)
->setUserId(filter_input(INPUT_COOKIE, 'msz_uid', FILTER_SANITIZE_NUMBER_INT) ?? 0)