bug 968089 mysqli fix

This commit is contained in:
Marc Delisle
2004-06-10 17:17:58 +00:00
parent f776451297
commit 041245c24d
3 changed files with 31 additions and 10 deletions

View File

@@ -7,11 +7,9 @@ $Source$
2004-06-10 Marc Delisle <lem9@users.sourceforge.net>
* libraries/auth/config.auth.lib.php, libraries/dbi/mysql.dbi.lib.php,
libraries/dbi/mysql.dbi.lib.php,
lang/*: bug 968089: catch error when server is not responding
and show an appropriate message
TODO: for mysqli
* left.php: undefined variable
2004-06-09 Alexander M. Turek <me@derrabus.de>

View File

@@ -110,8 +110,10 @@ h1 {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo
// (note: it's true that they could have a badly typed host name, but
// anyway the current $strAccessDeniedExplanation tells that the server
// rejected the connection, which is not really what happened)
// 2002 is the error given by mysqli
// 2003 is the error given by mysql
if (!isset($GLOBALS['errno']) || (isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2003)) {
if (!isset($GLOBALS['errno']) || (isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002) && $GLOBALS['errno'] != 2003) {
echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n";
}
PMA_mysqlDie($conn_error, '');

View File

@@ -177,18 +177,39 @@ function PMA_DBI_free_result($result) {
}
function PMA_DBI_getError($link = NULL) {
unset($GLOBALS['errno']);
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
// Do not stop now. We still can get the error code
// with mysqli_connect_errno()
// } else {
// return FALSE;
}
}
if (mysqli_connect_errno()) {
$error = mysqli_connect_errno();
$error_message = mysqli_connect_error();
} elseif (mysqli_errno($link)) {
$error = mysqli_errno($link);
$error_message = mysqli_error($link);
}
// keep the error number for further check after the call to PMA_DBI_getError()
if ($error) {
$GLOBALS['errno'] = $error;
} else {
return FALSE;
}
}
$error = mysqli_errno($link);
if ($error && PMA_MYSQL_INT_VERSION >= 40100) {
$error = '#' . ((string) $error) . ' - ' . mysqli_error($link);
if ($error && $error == 2002) {
$error = '#' . ((string) $error) . ' - ' . $GLOBALS['strServerNotResponding'];
} elseif ($error && PMA_MYSQL_INT_VERSION >= 40100) {
$error = '#' . ((string) $error) . ' - ' . $error_message;
} elseif ($error) {
$error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysqli_error($link));
$error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset($error_message);
}
return $error;
}