From b14c83d5b86989e913eb94634ef1e71651ed3406 Mon Sep 17 00:00:00 2001 From: zamrih Date: Sun, 21 May 2023 00:03:55 -0400 Subject: [PATCH] fix: return 503 http status code on db connect --- www/lib/Reply.php | 3 ++- www/lib/lib.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/www/lib/Reply.php b/www/lib/Reply.php index 261ccc74b..bae18c222 100644 --- a/www/lib/Reply.php +++ b/www/lib/Reply.php @@ -9,7 +9,6 @@ public static function ajax($data) $res = json_encode($data); - //die($res); return $res; } @@ -19,6 +18,8 @@ public static function ajaxDie($stat, $msg, $data_tr = '') $data['msg'] = $msg; $data['data'] = $data_tr; + http_response_code(503); + die(self::ajax($data)); } } diff --git a/www/lib/lib.php b/www/lib/lib.php index 3bcd1b764..1e8fe3ee2 100644 --- a/www/lib/lib.php +++ b/www/lib/lib.php @@ -214,7 +214,7 @@ private function load_config() { private function connect() { $this->load_config(); - $this->dblink = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname) or die(LANG_DIE_COULDNOTCONNECT); + $this->dblink = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname) or Reply::ajaxDie('service-unavailable-error', LANG_DIE_COULDNOTCONNECT); mysqli_real_query($this->dblink, "set names utf8;"); } public static function escapeString(&$string) {