mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Handle database exceptions properly (#8720)
Display the errors to the user Hide the query, unless APP_DEBUG=true in .env Much easier to display output for other exceptions now, just need to add a render() function to them
This commit is contained in:
committed by
Neil Lathwood
parent
e22642c73f
commit
43b54fcf39
@@ -78,7 +78,6 @@ function dbConnect($db_host = null, $db_user = '', $db_pass = '', $db_name = '',
|
||||
}
|
||||
|
||||
$database_link = @mysqli_connect('p:' . $db_host, $db_user, $db_pass, null, $db_port, $db_socket);
|
||||
mysqli_options($database_link, MYSQLI_OPT_LOCAL_INFILE, false);
|
||||
if ($database_link === false) {
|
||||
$error = mysqli_connect_error();
|
||||
if ($error == 'No such file or directory') {
|
||||
@@ -87,6 +86,8 @@ function dbConnect($db_host = null, $db_user = '', $db_pass = '', $db_name = '',
|
||||
throw new DatabaseConnectException($error);
|
||||
}
|
||||
|
||||
mysqli_options($database_link, MYSQLI_OPT_LOCAL_INFILE, false);
|
||||
|
||||
$database_db = mysqli_select_db($database_link, $db_name);
|
||||
if (!$database_db) {
|
||||
$db_create_sql = "CREATE DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_unicode_ci";
|
||||
|
Reference in New Issue
Block a user