Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2021-07-20 18:07:11 +0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2022-01-10 18:12:07 +0300
commita059cdba47689782499132ee454e71d4480b7e89 (patch)
tree9ce97cb7a0c1e6effcae241bbd23c30a372ff0bb /libraries
parent0c34fc85c446f307aed0bed9f558b4ffa546a567 (diff)
Add config directive to show/hide connection errors
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'libraries')
-rw-r--r--libraries/classes/Dbi/DbiMysqli.php46
-rw-r--r--libraries/config.default.php7
2 files changed, 43 insertions, 10 deletions
diff --git a/libraries/classes/Dbi/DbiMysqli.php b/libraries/classes/Dbi/DbiMysqli.php
index afd596ccd7..d0905eb00c 100644
--- a/libraries/classes/Dbi/DbiMysqli.php
+++ b/libraries/classes/Dbi/DbiMysqli.php
@@ -149,16 +149,29 @@ class DbiMysqli implements DbiExtension
$host = $server['host'];
}
- $return_value = mysqli_real_connect(
- $link,
- $host,
- $user,
- $password,
- '',
- $server['port'],
- $server['socket'],
- $client_flags
- );
+ if ($server['hide_connection_errors']) {
+ $return_value = @mysqli_real_connect(
+ $link,
+ $host,
+ $user,
+ $password,
+ '',
+ $server['port'],
+ $server['socket'],
+ $client_flags
+ );
+ } else {
+ $return_value = mysqli_real_connect(
+ $link,
+ $host,
+ $user,
+ $password,
+ '',
+ $server['port'],
+ $server['socket'],
+ $client_flags
+ );
+ }
if ($return_value === false || is_null($return_value)) {
/*
@@ -180,7 +193,20 @@ class DbiMysqli implements DbiExtension
);
$server['ssl'] = true;
return self::connect($user, $password, $server);
+ } elseif ($error_number === 1045 && $server['hide_connection_errors']) {
+ trigger_error(
+ sprintf(
+ __(
+ 'Error 1045: Access denied for user. Additional error information'
+ . ' may be available, but is being hidden by the %s configuration directive.'
+ ),
+ '[code][doc@cfg_Servers_hide_connection_errors]'
+ . '$cfg[\'Servers\'][$i][\'hide_connection_errors\'][/doc][/code]'
+ ),
+ E_USER_ERROR
+ );
}
+
return false;
}
diff --git a/libraries/config.default.php b/libraries/config.default.php
index e7cf828bff..fcd54c9a18 100644
--- a/libraries/config.default.php
+++ b/libraries/config.default.php
@@ -604,6 +604,13 @@ $cfg['Servers'][$i]['tracking_add_drop_table'] = true;
$cfg['Servers'][$i]['tracking_add_drop_database'] = true;
/**
+ * Whether to show or hide detailed MySQL/MariaDB connection errors on the login page.
+ *
+ * @global bool $cfg['Servers'][$i]['hide_connection_errors']
+ */
+$cfg['Servers'][$i]['hide_connection_errors'] = false;
+
+/**
* Default server (0 = no default server)
*
* If you have more than one server configured, you can set $cfg['ServerDefault']